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


PHP WP_Roles::add_cap方法代码示例

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


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

示例1: foreach

 /**
  * Adds plugin-specific caps to all roles so that 3rd party plugins can manage them
  */
 function add_caps()
 {
     $version = get_option('post_forking_cap_version');
     // Bail Early if we have already set the caps and aren't updating them
     if ($version !== false && $this->cap_version <= (int) $version) {
         return;
     }
     add_option('post_forking_cap_version', $this->cap_version, '', 'yes');
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     foreach ($wp_roles->role_names as $role => $label) {
         //if the role is a standard role, map the default caps, otherwise, map as a subscriber
         $caps = array_key_exists($role, $this->defaults) ? $this->defaults[$role] : $this->defaults['subscriber'];
         //loop and assign
         foreach ($caps as $cap => $grant) {
             //check to see if the user already has this capability, if so, don't re-add as that would override grant
             if (!isset($wp_roles->roles[$role]['capabilities'][$cap])) {
                 $wp_roles->add_cap($role, $cap, $grant);
             } else {
                 $wp_roles->remove_cap($role, $cap);
                 $wp_roles->add_cap($role, $cap, $grant);
             }
         }
     }
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:30,代码来源:capabilities.php

示例2: array

 /**
  * Init dokan user roles
  *
  * @since Dokan 1.0
  * @global WP_Roles $wp_roles
  */
 function user_roles()
 {
     global $wp_roles;
     if (class_exists('WP_Roles') && !isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     add_role('seller', __('Seller', 'dokan'), array('read' => true, 'publish_posts' => true, 'edit_posts' => true, 'delete_published_posts' => true, 'edit_published_posts' => true, 'delete_posts' => true, 'manage_categories' => true, 'moderate_comments' => true, 'unfiltered_html' => true, 'upload_files' => true, 'dokandar' => true));
     $wp_roles->add_cap('shop_manager', 'dokandar');
     $wp_roles->add_cap('administrator', 'dokandar');
 }
开发者ID:abcode619,项目名称:wpstuff,代码行数:16,代码来源:installer.php

示例3: action_plugins_loaded

 public function action_plugins_loaded()
 {
     global $wpdb;
     $db_version = get_option('un_version');
     if ($db_version == UN_VERSION) {
         return;
     }
     if (!$db_version) {
         add_option('un_version', UN_VERSION);
         $wpdb->query("UPDATE {$wpdb->postmeta} \n\t\t\t\tINNER JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id\n\t\t\t\tSET meta_key = '_email' \n\t\t\t\tWHERE meta_key = 'email' AND post_type = 'feedback'\n\t\t\t\t");
     }
     if (version_compare($db_version, '0.4') == -1) {
         $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_type = %s WHERE post_type = %s", FEEDBACK, 'feedback'));
         global $wp_roles;
         if (!isset($wp_roles)) {
             $wp_roles = new WP_Roles();
         }
         foreach (un_get_capable_roles() as $role) {
             foreach (un_get_feedback_capabilities() as $cap) {
                 $wp_roles->add_cap($role, $cap);
             }
         }
     }
     if (version_compare($db_version, '0.6') == -1) {
         $options = array(UN_USE_FONT, UN_FEEDBACK_BUTTON_TEXT, UN_FEEDBACK_BUTTON_COLOR, UN_FEEDBACK_BUTTON_TEXT_COLOR, UN_FEEDBACK_BUTTON_POSITION, UN_FEEDBACK_FORM_TITLE, UN_FEEDBACK_FORM_TEXT, UN_FEEDBACK_FORM_SHOW_SUMMARY, UN_FEEDBACK_FORM_SHOW_TYPE, UN_FEEDBACK_FORM_SHOW_EMAIL, UN_SUBMIT_FEEDBACK_BUTTON_TEXT, UN_THANKYOU_TITLE, UN_THANKYOU_TEXT, UN_ADMIN_NOTIFY_ON_FEEDBACK, UN_SUBMIT_FEEDBACK_BUTTON_TEXT, UN_SHOW_POWERED_BY, UN_FEEDBACK_BUTTON_SHOW_BORDER, UN_DISABLE_ON_MOBILES, UN_ENABLED, UN_LOAD_IN_FOOTER);
         foreach ($options as $option) {
             $value = get_option('un_' . $option);
             if ($value) {
                 un_set_option($option, $value);
             }
             delete_option('un_' . $option);
         }
     }
     update_option('un_version', UN_VERSION);
 }
开发者ID:congtrieu112,项目名称:anime,代码行数:35,代码来源:migrations.php

示例4: un_do_db_upgrade

function un_do_db_upgrade()
{
    global $un_default_options, $wp_roles, $wpdb;
    $icons = array('idea' => 'icon-lightbulb', 'question' => 'icon-question-sign', 'problem' => 'icon-exclamation-sign', 'praise' => 'icon-heart');
    $plural = array('idea' => __('Ideas', 'usernoise'), 'question' => __('Questions', 'usernoise'), 'problem' => __('Problems', 'usernoise'), 'praise' => __('Praises', 'usernoise'));
    $index = 0;
    $wpdb->un_termmeta = $wpdb->prefix . "un_termmeta";
    if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->un_termmeta}'") != $wpdb->un_termmeta) {
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        $sql = "CREATE TABLE `{$wpdb->un_termmeta}` (\n\t\t\t`meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t`un_term_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t`meta_key` varchar(255) DEFAULT NULL,\n\t\t\t`meta_value` longtext,\n\t\t\tPRIMARY KEY (`meta_id`),\n\t\t\tKEY `un_term_id` (`un_term_id`),\n\t\t\tKEY `meta_key` (`meta_key`)\n\t\t);";
        dbDelta($sql);
    }
    foreach (array('idea' => __('Idea', 'usernoise'), 'question' => __('Question', 'usernoise'), 'problem' => __('Problem', 'usernoise'), 'praise' => __('Praise', 'usernoise')) as $type => $value) {
        if (null == ($term = get_term_by('slug', $type, 'feedback_type', ARRAY_A))) {
            $term = wp_insert_term($value, FEEDBACK_TYPE, array('slug' => $type));
        }
        if (null == un_get_term_meta($term['term_id'], 'icon')) {
            un_add_term_meta($term['term_id'], 'icon', $icons[$type], true);
            un_add_term_meta($term['term_id'], 'plural', $plural[$type], true);
            un_add_term_meta($term['term_id'], 'position', $index, true);
        }
        $index++;
    }
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    foreach (un_get_capable_roles() as $role) {
        foreach (un_get_feedback_capabilities() as $cap) {
            $wp_roles->add_cap($role, $cap);
        }
    }
    update_option('un_db_revision', '2');
}
开发者ID:congtrieu112,项目名称:anime,代码行数:33,代码来源:db-upgrade.php

示例5:

 function add_cap($cap, $grant = true)
 {
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $this->capabilities[$cap] = $grant;
     $wp_roles->add_cap($this->name, $cap, $grant);
 }
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:9,代码来源:capabilities.php

示例6: wlb_install

function wlb_install()
{
    $WP_Roles = new WP_Roles();
    foreach (array('wlb_branding', 'wlb_navigation', 'wlb_login', 'wlb_color_scheme', 'wlb_options', 'wlb_role_manager', 'wlb_license', 'wlb_downloads', 'wlb_dashboard_tool') as $cap) {
        $WP_Roles->add_cap(WLB_ADMIN_ROLE, $cap);
    }
    include WLB_PATH . 'includes/install.php';
    if (function_exists('handle_wlb_install')) {
        handle_wlb_install('MWLB', WLB_PATH, WLB_PATH . 'options-panel/');
    }
}
开发者ID:emjayoh,项目名称:bhag,代码行数:11,代码来源:white-label-branding.php

示例7: addCapability

 /**
  *
  * @return type
  */
 public function addCapability()
 {
     $roles = new WP_Roles();
     $capability = trim(aam_Core_Request::post('capability'));
     if ($capability) {
         $normalized = str_replace(' ', '_', strtolower($capability));
         //add the capability to administrator's role as default behavior
         $roles->add_cap('administrator', $normalized);
         $response = array('status' => 'success', 'capability' => $normalized);
     } else {
         $response = array('status' => 'failure');
     }
     return json_encode($response);
 }
开发者ID:dot2006,项目名称:jobify,代码行数:18,代码来源:capability.php

示例8: add_roles

 public static function add_roles()
 {
     // moderator and admin role
     $parti_cap = array('ap_read_question' => true, 'ap_read_answer' => true, 'ap_new_question' => true, 'ap_new_answer' => true, 'ap_new_comment' => true, 'ap_edit_question' => true, 'ap_edit_answer' => true, 'ap_edit_comment' => true, 'ap_hide_question' => true, 'ap_hide_answer' => true, 'ap_delete_comment' => true, 'ap_vote_up' => true, 'ap_vote_down' => true, 'ap_vote_flag' => true, 'ap_vote_close' => true, 'ap_upload_cover' => true, 'ap_message' => true, 'ap_new_tag' => true);
     $editor_cap = array('ap_read_question' => true, 'ap_read_answer' => true, 'ap_new_question' => true, 'ap_new_answer' => true, 'ap_new_comment' => true, 'ap_edit_question' => true, 'ap_edit_answer' => true, 'ap_edit_comment' => true, 'ap_delete_question' => true, 'ap_delete_answer' => true, 'ap_delete_comment' => true, 'ap_vote_up' => true, 'ap_vote_down' => true, 'ap_vote_flag' => true, 'ap_vote_close' => true, 'ap_edit_others_question' => true, 'ap_edit_others_answer' => true, 'ap_edit_others_comment' => true, 'ap_upload_cover' => true, 'ap_message' => true, 'ap_new_tag' => true);
     $mod_cap = array('ap_read_question' => true, 'ap_read_answer' => true, 'ap_new_question' => true, 'ap_new_answer' => true, 'ap_new_comment' => true, 'ap_edit_question' => true, 'ap_edit_answer' => true, 'ap_edit_comment' => true, 'ap_delete_question' => true, 'ap_delete_answer' => true, 'ap_delete_comment' => true, 'ap_vote_up' => true, 'ap_vote_down' => true, 'ap_vote_flag' => true, 'ap_vote_close' => true, 'ap_edit_others_question' => true, 'ap_edit_others_answer' => true, 'ap_edit_others_comment' => true, 'ap_hide_others_question' => true, 'ap_hide_others_answer' => true, 'ap_hide_others_comment' => true, 'ap_delete_others_question' => true, 'ap_delete_others_answer' => true, 'ap_delete_others_comment' => true, 'ap_change_label' => true, 'ap_upload_cover' => true, 'ap_message' => true, 'ap_new_tag' => true);
     add_role('ap_participant', __('Participant', 'ap'), $parti_cap);
     add_role('ap_editor', __('Editor', 'ap'), $editor_cap);
     add_role('ap_moderator', __('Moderator', 'ap'), $mod_cap);
     // add capability to existing roles
     $roles = array('administrator', 'subscriber', 'ap_participant', 'ap_editor', 'ap_moderator');
     $roles_obj = new WP_Roles();
     foreach ($roles as $role_name) {
         if ($role_name == 'administrator') {
             foreach ($mod_cap as $k => $grant) {
                 $roles_obj->add_cap($role_name, $k);
             }
         } elseif ($role_name == 'ap_participant') {
             foreach ($parti_cap as $k => $grant) {
                 $roles_obj->add_cap($role_name, $k);
             }
         } elseif ($role_name == 'ap_editor') {
             foreach ($editor_cap as $k => $grant) {
                 $roles_obj->add_cap($role_name, $k);
             }
         } elseif ($role_name == 'ap_moderator') {
             foreach ($mod_cap as $k => $grant) {
                 $roles_obj->add_cap($role_name, $k);
             }
         } else {
             foreach ($parti_cap as $k => $grant) {
                 $roles_obj->add_cap($role_name, $k);
             }
         }
     }
 }
开发者ID:jessor,项目名称:anspress,代码行数:36,代码来源:activate.php

示例9: handle_rhc_install

/**
 * 
 *
 * @version $Id$
 * @copyright 2003 
 **/
function handle_rhc_install()
{
    //----for taxonomy metadata support
    global $wpdb;
    $charset_collate = '';
    if (!empty($wpdb->charset)) {
        $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
    }
    if (!empty($wpdb->collate)) {
        $charset_collate .= " COLLATE {$wpdb->collate}";
    }
    $tables = $wpdb->get_results("show tables like '{$wpdb->prefix}taxonomymeta'");
    if (!count($tables)) {
        $wpdb->query("CREATE TABLE {$wpdb->prefix}taxonomymeta (\r\n\t   meta_id bigint(20) unsigned NOT NULL auto_increment,\r\n\t   taxonomy_id bigint(20) unsigned NOT NULL default '0',\r\n\t   meta_key varchar(255) default NULL,\r\n\t   meta_value longtext,\r\n\t   PRIMARY KEY  (meta_id),\r\n\t   KEY taxonomy_id (taxonomy_id),\r\n\t   KEY meta_key (meta_key)\r\n\t ) {$charset_collate};");
    }
    $tables = $wpdb->get_results("show tables like '{$wpdb->prefix}rhc_cache'");
    if (!count($tables)) {
        $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}rhc_cache` (\r\n  `request_md5` char(32) NOT NULL,\r\n  `user_id` int(11) NOT NULL DEFAULT '0',\r\n  `cdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n  `action` varchar(50) DEFAULT NULL,\r\n  `response` longtext NOT NULL,\r\n  PRIMARY KEY (`request_md5`,`user_id`)\r\n) {$charset_collate};");
    }
    $tables = $wpdb->get_results("show tables like '{$wpdb->prefix}rhc_events'");
    if (!count($tables)) {
        $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}rhc_events` (\r\n  `event_start` datetime NOT NULL,\r\n  `event_end` datetime NOT NULL,\r\n  `post_id` bigint(20) NOT NULL,\r\n  `allday` tinyint(4) NOT NULL DEFAULT '0',\r\n  `number` int(11) NOT NULL DEFAULT '0',\r\n  PRIMARY KEY (`event_start`,`post_id`),\r\n  KEY `event_end` (`event_end`,`post_id`),\r\n  KEY `event_start` (`event_start`,`event_end`)\r\n) {$charset_collate};");
    }
    //---- Capabilities for the rhcvents custom post type
    $WP_Roles = new WP_Roles();
    foreach (array('calendarize_author', 'edit_' . RHC_CAPABILITY_TYPE, 'read_' . RHC_CAPABILITY_TYPE, 'delete_' . RHC_CAPABILITY_TYPE, 'delete_' . RHC_CAPABILITY_TYPE . 's', 'edit_' . RHC_CAPABILITY_TYPE . 's', 'edit_others_' . RHC_CAPABILITY_TYPE . 's', 'edit_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_private_' . RHC_CAPABILITY_TYPE . 's', 'delete_others_' . RHC_CAPABILITY_TYPE . 's', 'publish_' . RHC_CAPABILITY_TYPE . 's', 'read_private_' . RHC_CAPABILITY_TYPE . 's', 'manage_' . RHC_VENUE, 'manage_' . RHC_CALENDAR, 'manage_' . RHC_ORGANIZER, 'rhc_options', 'rhc_license') as $cap) {
        $WP_Roles->add_cap(RHC_ADMIN_ROLE, $cap);
    }
    //----
    global $rhc_plugin;
    include RHC_PATH . 'includes/bundle_default_custom_fields.php';
    if (isset($postinfo_boxes)) {
        //--save:
        $options = get_option($rhc_plugin->options_varname);
        $options = is_array($options) ? $options : array();
        if (!isset($options['postinfo_boxes'])) {
            $options['postinfo_boxes'] = $postinfo_boxes;
            update_option($rhc_plugin->options_varname, $options);
        }
        //--
    }
    add_option('rhc_options_redirect', true);
    add_option('rhc_setup', true);
    $rhc_plugin->update_option('data-last-modified', gmdate("D, d M Y H:i:s") . " GMT");
}
开发者ID:kaydwithers,项目名称:crossfittanjongpagar,代码行数:51,代码来源:install.php

示例10: foreach

 /**
  * Adds plugin-specific caps to all roles so that 3rd party plugins can manage them
  */
 function add_caps()
 {
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     foreach ($wp_roles->role_names as $role => $label) {
         //if the role is a standard role, map the default caps, otherwise, map as a subscriber
         $caps = array_key_exists($role, $this->defaults) ? $this->defaults[$role] : $this->defaults['subscriber'];
         //loop and assign
         foreach ($caps as $cap => $grant) {
             //check to see if the user already has this capability, if so, don't re-add as that would override grant
             if (!isset($wp_roles->roles[$role]['capabilities'][$cap])) {
                 $wp_roles->add_cap($role, $cap, $grant);
             }
         }
     }
 }
开发者ID:fancyguy,项目名称:post-forking,代码行数:21,代码来源:capabilities.php

示例11: orbis_update_roles

function orbis_update_roles($roles)
{
    global $wp_roles;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    foreach ($roles as $role => $data) {
        if (isset($data['display_name'], $data['capabilities'])) {
            $display_name = $data['display_name'];
            $capabilities = $data['capabilities'];
            if ($wp_roles->is_role($role)) {
                foreach ($capabilities as $cap => $grant) {
                    $wp_roles->add_cap($role, $cap, $grant);
                }
            } else {
                $wp_roles->add_role($role, $display_name, $capabilities);
            }
        }
    }
}
开发者ID:joffcrabtree,项目名称:wp-orbis-keychains,代码行数:20,代码来源:post.php

示例12: handle_rhc_install

/**
 * 
 *
 * @version $Id$
 * @copyright 2003 
 **/
function handle_rhc_install()
{
    //----for taxonomy metadata support
    global $wpdb;
    $charset_collate = '';
    if (!empty($wpdb->charset)) {
        $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
    }
    if (!empty($wpdb->collate)) {
        $charset_collate .= " COLLATE {$wpdb->collate}";
    }
    $tables = $wpdb->get_results("show tables like '{$wpdb->prefix}taxonomymeta'");
    if (!count($tables)) {
        $wpdb->query("CREATE TABLE {$wpdb->prefix}taxonomymeta (\n\t   meta_id bigint(20) unsigned NOT NULL auto_increment,\n\t   taxonomy_id bigint(20) unsigned NOT NULL default '0',\n\t   meta_key varchar(255) default NULL,\n\t   meta_value longtext,\n\t   PRIMARY KEY  (meta_id),\n\t   KEY taxonomy_id (taxonomy_id),\n\t   KEY meta_key (meta_key)\n\t ) {$charset_collate};");
    }
    //---- Capabilities for the rhcvents custom post type
    $WP_Roles = new WP_Roles();
    foreach (array('calendarize_author', 'edit_' . RHC_CAPABILITY_TYPE, 'read_' . RHC_CAPABILITY_TYPE, 'delete_' . RHC_CAPABILITY_TYPE, 'edit_' . RHC_CAPABILITY_TYPE . 's', 'edit_others_' . RHC_CAPABILITY_TYPE . 's', 'edit_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_private_' . RHC_CAPABILITY_TYPE . 's', 'delete_others_' . RHC_CAPABILITY_TYPE . 's', 'publish_' . RHC_CAPABILITY_TYPE . 's', 'read_private_' . RHC_CAPABILITY_TYPE . 's', 'manage_' . RHC_VENUE, 'manage_' . RHC_CALENDAR, 'manage_' . RHC_ORGANIZER) as $cap) {
        $WP_Roles->add_cap(RHC_ADMIN_ROLE, $cap);
    }
}
开发者ID:TheMysticalSock,项目名称:westmichigansymphony,代码行数:27,代码来源:install.php

示例13: eventon_init_caps

function eventon_init_caps()
{
    global $wp_roles;
    //print_r($wp_roles);
    if (class_exists('WP_Roles')) {
        if (!isset($wp_roles)) {
            $wp_roles = new WP_Roles();
        }
    }
    $capabilities = eventon_get_core_capabilities();
    foreach ($capabilities as $cap_group) {
        foreach ($cap_group as $cap) {
            $wp_roles->add_cap('administrator', $cap);
        }
    }
}
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:16,代码来源:eventon-core-functions.php

示例14: sp_add_caps

function sp_add_caps()
{
    global $wp_roles;
    if (class_exists('WP_Roles') && !isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $wp_roles->add_cap('administrator', 'SPF Manage Options', false);
    $wp_roles->add_cap('administrator', 'SPF Manage Forums', false);
    $wp_roles->add_cap('administrator', 'SPF Manage User Groups', false);
    $wp_roles->add_cap('administrator', 'SPF Manage Permissions', false);
    $wp_roles->add_cap('administrator', 'SPF Manage Components', false);
    $wp_roles->add_cap('administrator', 'SPF Manage Admins', false);
    $wp_roles->add_cap('administrator', 'SPF Manage Users', false);
    $wp_roles->add_cap('administrator', 'SPF Manage Profiles', false);
    $wp_roles->add_cap('administrator', 'SPF Manage Toolbox', false);
    $wp_roles->add_cap('administrator', 'SPF Manage Plugins', false);
    $wp_roles->add_cap('administrator', 'SPF Manage Themes', false);
    $wp_roles->add_cap('administrator', 'SPF Manage Integration', false);
}
开发者ID:ashanrupasinghe,项目名称:govforuminstalledlocal,代码行数:19,代码来源:spa-support.php

示例15: duplicate_roles_for_new_blog

 /**
  * every time when new blog created - duplicate to it roles from the main blog (1)  
  * @global wpdb $wpdb
  * @global WP_Roles $wp_roles
  * @param int $blog_id
  * @param int $user_id
  *
  */
 public function duplicate_roles_for_new_blog($blog_id)
 {
     global $wpdb, $wp_roles;
     // get Id of 1st (main) blog
     $main_blog_id = $this->lib->get_main_blog_id();
     if (empty($main_blog_id)) {
         return;
     }
     $current_blog = $wpdb->blogid;
     switch_to_blog($main_blog_id);
     $main_roles = new WP_Roles();
     // get roles from primary blog
     $default_role = get_option('default_role');
     // get default role from primary blog
     switch_to_blog($blog_id);
     // switch to the new created blog
     $main_roles->use_db = false;
     // do not touch DB
     $main_roles->add_cap('administrator', 'dummy_123456');
     // just to save current roles into new blog
     $main_roles->role_key = $wp_roles->role_key;
     $main_roles->use_db = true;
     // save roles into new blog DB
     $main_roles->remove_cap('administrator', 'dummy_123456');
     // remove unneeded dummy capability
     update_option('default_role', $default_role);
     // set default role for new blog as it set for primary one
     switch_to_blog($current_blog);
     // return to blog where we were at the begin
 }
开发者ID:Kylemurray25,项目名称:wmlmusicguide,代码行数:38,代码来源:class-user-role-editor.php


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