當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WP_User::__get方法代碼示例

本文整理匯總了PHP中WP_User::__get方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_User::__get方法的具體用法?PHP WP_User::__get怎麽用?PHP WP_User::__get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WP_User的用法示例。


在下文中一共展示了WP_User::__get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __get

 /**
  * Magic getter method. Looks for the specified key in the mapped keys before using WP_User's __get method. 
  *
  * @return  mixed
  * @access  public
  * @since   1.0.0
  */
 public function __get($key)
 {
     $mapped_keys = $this->get_mapped_keys();
     if (array_key_exists($key, $mapped_keys)) {
         $key = $mapped_keys[$key];
     }
     return parent::__get($key);
 }
開發者ID:altatof,項目名稱:Charitable,代碼行數:15,代碼來源:class-charitable-user.php

示例2:

 function __get($key)
 {
     if ($key == 'assignments') {
         return $this->getAssignments();
     } else {
         // fallback to default WP_User magic method
         return parent::__get($key);
     }
 }
開發者ID:Cywaithaka,項目名稱:bwawwp,代碼行數:9,代碼來源:example-24.php

示例3: admin_user_rights

 /**
  * Assign the 'DJ' role to an administrator
  *
  * @since	1.3
  * @param	int	$user_id	User ID.
  * @param	int	$old_data	Object containing user's data prior to update.
  * @return
  */
 public function admin_user_rights($user_id, $old_data)
 {
     if (!user_can($user_id, 'administrator')) {
         return;
     }
     // Retrieve the current user object after the profile update
     $user = new WP_User($user_id);
     $is_staff = $user->__get('_mdjm_event_staff');
     $required_roles = $user->__get('_mdjm_event_roles');
     $make_admin = $user->__get('_mdjm_event_admin');
     $mdjm_roles = mdjm_get_roles();
     if (!empty($is_staff) && !empty($required_roles)) {
         // Reset roles and caps before applying updates due to some wierd bug
         foreach ($mdjm_roles as $role_id => $role_name) {
             $user->remove_role($role_id);
         }
         $user->remove_cap('mdjm_employee');
         foreach ($required_roles as $role_id) {
             $user->add_role($role_id);
         }
         $user->add_cap('mdjm_employee');
         delete_user_meta($user->ID, '_mdjm_event_roles');
     } else {
         foreach ($mdjm_roles as $role_id => $role_name) {
             $user->remove_role($role_id);
         }
         $user->remove_cap('mdjm_employee');
     }
     $permissions = new MDJM_Permissions();
     if (!empty($make_admin)) {
         $permissions->make_admin($user->ID);
         $user->add_cap('mdjm_employee');
     } else {
         $permissions->make_admin($user->ID, true);
         $user->remove_cap('mdjm_employee');
     }
 }
開發者ID:mdjm,項目名稱:mobile-dj-manager,代碼行數:45,代碼來源:class-mdjm-users.php


注:本文中的WP_User::__get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。