当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_Roles::remove_role方法代码示例

本文整理汇总了PHP中WP_Roles::remove_role方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Roles::remove_role方法的具体用法?PHP WP_Roles::remove_role怎么用?PHP WP_Roles::remove_role使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Roles的用法示例。


在下文中一共展示了WP_Roles::remove_role方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

 /**
  * Delete User Role and all User's in role if requested
  * 
  * @param boolean $delete_users
  * 
  * @return boolean
  * 
  * @access public
  */
 public function delete($delete_users = false)
 {
     $role = new WP_Roles();
     if ($this->getId() !== 'administrator') {
         if ($delete_users) {
             if (current_user_can('delete_users')) {
                 //delete users first
                 $users = new WP_User_Query(array('number' => '', 'blog_id' => get_current_blog_id(), 'role' => $this->getId()));
                 foreach ($users->get_results() as $user) {
                     //user can not delete himself
                     if ($user instanceof WP_User && $user->ID != get_current_user_id()) {
                         wp_delete_user($user->ID);
                     }
                 }
                 $role->remove_role($this->getId());
                 $status = true;
             } else {
                 $status = false;
             }
         } else {
             $role->remove_role($this->getId());
             $status = true;
         }
     } else {
         $status = false;
     }
     return $status;
 }
开发者ID:subhadip-sahoo,项目名称:wp-project1,代码行数:37,代码来源:role.php

示例2: remove_roles

 public function remove_roles()
 {
     global $wp_roles;
     if (class_exists('WP_Roles')) {
         if (!isset($wp_roles)) {
             $wp_roles = new WP_Roles();
         }
     }
     $wp_roles->remove_role('ap_participant');
     $wp_roles->remove_role('ap_editor');
     $wp_roles->remove_role('ap_moderator');
 }
开发者ID:CasteyDaSilva,项目名称:anspress,代码行数:12,代码来源:class-roles-cap.php

示例3:

 /**
  * Remove some unneeded roles and change role names
  *
  * @since 1.0.0
  */
 function change_roles()
 {
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     // Remove roles which are not used
     $wp_roles->remove_role("contributor");
     $wp_roles->remove_role("author");
     // Rename other roles for more usability
     // Change them for your language
     $wp_roles->roles['subscriber']['name'] = __('Basic User', 'simplified-user-roles');
     $wp_roles->role_names['subscriber'] = __('Basic User', 'simplified-user-roles');
     $wp_roles->roles['editor']['name'] = __('Staff', 'simplified-user-roles');
     $wp_roles->role_names['editor'] = __('Staff', 'simplified-user-roles');
     $wp_roles->roles['administrator']['name'] = __('Developer', 'simplified-user-roles');
     $wp_roles->role_names['administrator'] = __('Developer', 'simplified-user-roles');
 }
开发者ID:KeksiLabs,项目名称:simplified-user-roles,代码行数:23,代码来源:simplified-user-roles.php

示例4: delete

 /**
  * Delete User Role 
  *
  * @return boolean
  *
  * @access public
  */
 public function delete()
 {
     $status = false;
     $role = new WP_Roles();
     if ($this->getId() !== 'administrator') {
         $count = count_users();
         $stats = $count['avail_roles'];
         if (empty($stats[$this->getId()])) {
             $role->remove_role($this->getId());
             $status = true;
         }
     }
     return $status;
 }
开发者ID:vanlong200880,项目名称:uni,代码行数:21,代码来源:Role.php

示例5: remove_role

/**
 * Remove role, if it exists.
 *
 * @see WP_Roles::remove_role() Uses method to remove role.
 * @since 2.0.0
 *
 * @param string $role Role name.
 * @return null
 */
function remove_role($role)
{
    global $wp_roles;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    return $wp_roles->remove_role($role);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:17,代码来源:capabilities.php

示例6: remove_role

 /**
  * Remove a role
  *
  * @brief Role
  *
  * @param string $role
  */
 public function remove_role($role)
 {
     parent::remove_role($role);
     unset($this->extend_data[$role]);
     update_option(self::OPTION_KEY, $this->extend_data);
     /**
      * Fires when a role is removed.
      *
      * @since 1.6.0
      *
      * @param string $role The role key.
      */
     do_action('wpdk_user_roles_removed_role', $role);
 }
开发者ID:wpxtreme,项目名称:wpdk,代码行数:21,代码来源:wpdk-user-roles.php

示例7: foreach

 function pop_handle_save($pop)
 {
     global $wlb_plugin;
     if ($wlb_plugin->options_varname != $pop->options_varname) {
         return;
     }
     if (!$wlb_plugin->is_wlb_administrator()) {
         return;
     }
     if (isset($_POST['ROLES']) && is_array($_POST['ROLES']) && count($_POST['ROLES']) > 0) {
         global $wp_roles;
         $WP_Roles = new WP_Roles();
         $all_caps = $this->get_all_caps_from_wp_roles($WP_Roles);
         foreach ($_POST['ROLES'] as $role_id => $capabilities) {
             foreach ($all_caps as $capability) {
                 if (array_key_exists($capability, $capabilities)) {
                     //echo "Adding $capability to role $role_id<br />";
                     $WP_Roles->add_cap($role_id, $capability);
                 } else {
                     //echo "Removing $capability from role $role_id<br />";
                     $WP_Roles->remove_cap($role_id, $capability);
                 }
             }
         }
         if (trim($_POST['new_role_name']) != '') {
             $WP_Roles->add_role(strtolower(str_replace(" ", "_", $_POST['new_role_name'])), $_POST['new_role_name']);
             $WP_Roles = new WP_Roles();
         }
         if (trim($_POST['new_capability']) != '' && isset($_POST['role_to_add_caps']) && $_POST['role_to_add_caps'] != '') {
             $WP_Roles->add_cap($_POST['role_to_add_caps'], strtolower(str_replace(" ", "_", $_POST['new_capability'])));
             $WP_Roles = new WP_Roles();
         }
         if (isset($_POST['f_delete_role'])) {
             $WP_Roles->remove_role($_POST['role_to_delete']);
             //!!
             $WP_Roles = new WP_Roles();
         }
         $wp_roles = $WP_Roles;
     }
 }
开发者ID:emjayoh,项目名称:bhag,代码行数:40,代码来源:class.wlb_capabilities.php

示例8: roles

	/**
	 * Installed roles and capabilities used for Ecart
	 *
	 * Capabilities						Role
	 * _______________________________________________
	 *
	 * ecart_settings					admin
	 * ecart_settings_checkout
	 * ecart_settings_payments
	 * ecart_settings_shipping
	 * ecart_settings_taxes
	 * ecart_settings_presentation
	 * ecart_settings_system
	 * ecart_settings_update
	 * ecart_financials					merchant
	 * ecart_promotions
	 * ecart_products
	 * ecart_categories
	 * ecart_orders						ecart-csr
	 * ecart_customers
	 * ecart_menu
	 *
	 * @author John Dillick
	 * @since 1.1
	 *
	 **/
	function roles () {
		global $wp_roles; // WP_Roles roles container
		if(!$wp_roles) $wp_roles = new WP_Roles();
		$ecart_roles = array('administrator'=>'Administrator', 'ecart-merchant'=>__('Merchant','Ecart'), 'ecart-csr'=>__('Customer Service Rep','Ecart'));
		$caps['ecart-csr'] = array('ecart_customers', 'ecart_orders','ecart_menu','read');
		$caps['ecart-merchant'] = array_merge($caps['ecart-csr'],
			array('ecart_categories',
				'ecart_products',
				'ecart_promotions',
				'ecart_financials',
				'ecart_export_orders',
				'ecart_export_customers',
				'ecart_delete_orders',
				'ecart_delete_customers'));
		$caps['administrator'] = array_merge($caps['ecart-merchant'],
			array('ecart_settings_update',
				'ecart_settings_system',
				'ecart_settings_presentation',
				'ecart_settings_taxes',
				'ecart_settings_shipping',
				'ecart_settings_payments',
				'ecart_settings_checkout',
				'ecart_settings'));
		$wp_roles->remove_role('ecart-csr');
		$wp_roles->remove_role('ecart-merchant');

		foreach($ecart_roles as $role => $display) {
			if($wp_roles->is_role($role)) {
				foreach($caps[$role] as $cap) $wp_roles->add_cap($role, $cap, true);
			} else {
				$wp_roles->add_role($role, $display, array_combine($caps[$role],array_fill(0,count($caps[$role]),true)));
			}
		}
	}
开发者ID:robbiespire,项目名称:paQui,代码行数:60,代码来源:Install.php

示例9: wps_change_roles

function wps_change_roles()
{
    global $wp_roles;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $wp_roles->add_role('student', 'Student', array('read' => true, 'edit_posts' => true, 'delete_posts' => true));
    $wp_roles->remove_role('teacher');
    $wp_roles->roles['author']['name'] = 'Parent';
    $wp_roles->role_names['author'] = 'Parent';
    $wp_roles->roles['editor']['name'] = 'Teacher';
    $wp_roles->role_names['editor'] = 'Teacher';
}
开发者ID:johnnygan,项目名称:cphedu,代码行数:13,代码来源:functions.php

示例10: bum_manage_roles

/**
 * Handle role stuff
 */
function bum_manage_roles()
{
    $action = isset($_POST['action']) ? $_POST['action'] : $_GET['action'];
    switch ($action) {
        case 'delete-user-role':
            //get vars
            $name = $_GET['delete-id'];
            $roles = new WP_Roles();
            $roles->remove_role($name);
            break;
        case 'edit-user-role':
            //get vars
            $edit_id = $_POST['edit-id'];
        case 'add-user-role':
            //get vars
            $allow = $_POST['role-allow'] == 'yes' ? 'yes' : 'no';
            $name = $_POST['role-name'];
            $id = $_POST['role-slug'] == '' ? sanitize_title($name) : $_POST['role-slug'];
            //add role
            $roles = new WP_Roles();
            if (isset($edit_id)) {
                $roles->remove_role($edit_id);
            }
            $roles->add_role($id, $name, array());
            //save registration part in hidden taxonomy
            $term = get_term_by('slug', sanitize_title(isset($edit_id) ? $edit_id : $id), BUM_HIDDEN_ROLES);
            if ($term) {
                wp_update_term($term->term_id, BUM_HIDDEN_ROLES, array('description' => $allow));
            } else {
                wp_insert_term(sanitize_title(isset($edit_id) ? $edit_id : $id), BUM_HIDDEN_ROLES, array('description' => $allow));
            }
            break;
    }
    echo bum_get_show_view('bum-manage-roles');
}
开发者ID:Jonathonbyrd,项目名称:better-user-management,代码行数:38,代码来源:better-user-management.php

示例11: removeSuperAdminRole

 protected function removeSuperAdminRole()
 {
     //update the role capabilities and remove super admin role
     $roles = new WP_Roles();
     //get all capabilities first and merge them in one array
     $capabilities = array();
     foreach ($roles->role_objects as $role) {
         $capabilities = array_merge($capabilities, $role->capabilities);
     }
     if (count($capabilities)) {
         //update administrator capability role
         if ($admin = $roles->get_role('administrator')) {
             foreach ($capabilities as $capability => $grand) {
                 $admin->add_cap($capability);
             }
         } else {
             $roles->add_role('administrator', 'Administrator', $capabilities);
         }
         //remove Super Admin Role
         $roles->remove_role('super_admin');
     }
 }
开发者ID:dot2006,项目名称:jobify,代码行数:22,代码来源:migrate.php


注:本文中的WP_Roles::remove_role方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。