当前位置: 首页>>代码示例>>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;未经允许,请勿转载。