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


PHP add_role函数代码示例

本文整理汇总了PHP中add_role函数的典型用法代码示例。如果您正苦于以下问题:PHP add_role函数的具体用法?PHP add_role怎么用?PHP add_role使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: __construct

 public function __construct()
 {
     add_action('admin_init', function () {
         if (!is_a(get_role('developer'), 'WP_Role')) {
             global $wp_roles;
             $allRoles = $wp_roles->roles;
             $allCapabilities = [];
             foreach ($allRoles as $key => $role) {
                 $allCapabilities = array_merge($allCapabilities, $role['capabilities']);
             }
             foreach ($allCapabilities as $key => &$capability) {
                 $capability = 1;
             }
             $allCapabilities['develop'] = 1;
             add_role('developer', __('Developer'), $allCapabilities);
         }
     });
     add_action('admin_init', function () {
         if (!is_a(get_role('privileged_editor'), 'WP_Role')) {
             $editor = get_role('editor');
             $editorCapabilities = $editor->capabilities;
             $privilegedCapabilities = ['active_plugins' => true, 'add_users' => true, 'create_users' => true, 'edit_theme_options' => true, 'edit_users' => true, 'export' => true, 'install_plugins' => true, 'list_users' => true, 'manage_options' => true, 'update_core' => true, 'update_plugins' => true];
             $finalCapabilities = array_merge($editorCapabilities, $privilegedCapabilities);
             add_role('privileged_editor', __('Privileged Editor'), $finalCapabilities);
         }
     });
 }
开发者ID:tagmeo,项目名称:framework,代码行数:27,代码来源:Roles.php

示例2: create_wp_appkit_user_role

 public static function create_wp_appkit_user_role()
 {
     remove_role(self::wpak_editor_role);
     $capabilities = array('wpak_edit_apps' => true, 'read' => true, 'level_0' => true, 'subscriber' => true, 'edit_wpak_app' => true, 'edit_wpak_apps' => true, 'read_wpak_apps' => true, 'delete_wpak_apps' => true, 'delete_others_wpak_apps' => true, 'delete_published_wpak_apps' => true, 'edit_others_wpak_apps' => true, 'publish_wpak_apps' => true);
     $capabilities = apply_filters('wpak_editor_role_capabilities', $capabilities);
     $wpak_role = add_role(self::wpak_editor_role, __('WP AppKit App Editor', WpAppKit::i18n_domain), $capabilities);
 }
开发者ID:hiddenpearls,项目名称:wp-appkit,代码行数:7,代码来源:user-permissions.php

示例3: add_theme_caps

function add_theme_caps()
{
    if (!get_role('member')) {
        $capabilities = array('create_announcements' => true, 'edit_others_announcements' => true, 'delete_pages' => true, 'delete_published_pages' => true, 'edit_pages' => true, 'edit_others_pages' => true, 'edit_published_pages' => true, 'publish_pages' => true, 'gravityforms_edit_forms' => true, 'gravityforms_view_entries' => true, 'read' => true, 'manage_categories' => true, 'delete_posts' => true, 'delete_published_posts' => true, 'edit_posts' => true, 'edit_published_posts' => true, 'edit_others_posts' => true, 'publish_posts' => true);
        add_role('member', 'Club Member', $capabilities);
    }
    $editor = get_role('editor');
    if (!$editor->capabilities['create_announcements']) {
        $editor->add_cap('edit_home_page');
        $editor->add_cap('create_announcements');
        $editor->add_cap('create_mailchimp_campaigns');
        $editor->add_cap('create_speaker_programs');
        $editor->add_cap('edit_speaker_programs');
        $editor->add_cap('delete_others_announcements');
        $editor->add_cap('edit_others_announcements');
    }
    $admin = get_role('administrator');
    if (!$admin->capabilities['create_announcements']) {
        $admin->add_cap('edit_home_page');
        $admin->add_cap('create_announcements');
        $admin->add_cap('create_mailchimp_campaigns');
        $admin->add_cap('create_speaker_programs');
        $admin->add_cap('edit_speaker_programs');
        $admin->add_cap('delete_others_announcements');
        $admin->add_cap('edit_others_announcements');
    }
}
开发者ID:nmedia82,项目名称:rotary,代码行数:27,代码来源:custom-capabilities.php

示例4: add_roles

 /**
  * Add new shop roles with default WP caps
  *
  * @access public
  * @since 1.4.4
  * @return void
  */
 public function add_roles()
 {
     add_role('shop_manager', __('Shop Manager', 'edd'), array('read' => true, 'edit_posts' => true, 'delete_posts' => true, 'unfiltered_html' => true, 'upload_files' => true, 'export' => true, 'import' => true, 'delete_others_pages' => true, 'delete_others_posts' => true, 'delete_pages' => true, 'delete_private_pages' => true, 'delete_private_posts' => true, 'delete_published_pages' => true, 'delete_published_posts' => true, 'edit_others_pages' => true, 'edit_others_posts' => true, 'edit_pages' => true, 'edit_posts' => true, 'edit_private_pages' => true, 'edit_private_posts' => true, 'edit_published_pages' => true, 'edit_published_posts' => true, 'manage_categories' => true, 'manage_links' => true, 'moderate_comments' => true, 'publish_pages' => true, 'publish_posts' => true, 'read_private_pages' => true, 'read_private_posts' => true));
     add_role('shop_accountant', __('Shop Accountant', 'edd'), array('read' => true, 'edit_posts' => false, 'delete_posts' => false));
     add_role('shop_worker', __('Shop Worker', 'edd'), array('read' => true, 'edit_posts' => false, 'upload_files' => true, 'delete_posts' => false));
     add_role('shop_vendor', __('Shop Vendor', 'edd'), array('read' => true, 'edit_posts' => false, 'upload_files' => true, 'delete_posts' => false));
 }
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:14,代码来源:class-edd-roles.php

示例5: trav_after_setup_theme

 function trav_after_setup_theme()
 {
     add_role('trav_busowner', 'Business Owner');
     $role = get_role('trav_busowner');
     $role->add_cap('read');
     $role->add_cap('upload_files');
 }
开发者ID:BersnardC,项目名称:DROPINN,代码行数:7,代码来源:functions.php

示例6: plugin_activation

 /**
  * Activation hook to register a new Role and assign it our Contact Capabilities
  */
 function plugin_activation()
 {
     // Define our custom capabilities
     $customCaps = array('edit_others_contacts' => true, 'delete_others_contacts' => true, 'delete_private_contacts' => true, 'edit_private_contacts' => true, 'read_private_contacts' => true, 'edit_published_contacts' => true, 'publish_contacts' => true, 'delete_published_contacts' => true, 'edit_contacts' => true, 'delete_contacts' => true, 'edit_contact' => true, 'read_contact' => true, 'delete_contact' => true, 'read' => true);
     // Create our CRM role and assign the custom capabilities to it
     add_role('crm', __('CRM', 'ecrm'), $customCaps);
     // Add custom capabilities to Admin and Editor Roles
     $roles = array('administrator', 'editor');
     foreach ($roles as $roleName) {
         // Get role
         $role = get_role($roleName);
         // Check role exists
         if (is_null($role)) {
             continue;
         }
         // Iterate through our custom capabilities, adding them
         // to this role if they are enabled
         foreach ($customCaps as $capability => $enabled) {
             if ($enabled) {
                 // Add capability
                 $role->add_cap($capability);
             }
         }
     }
     // Add some of our custom capabilities to the Author Role
     $role = get_role('author');
     $role->add_cap('edit_contact');
     $role->add_cap('edit_contacts');
     $role->add_cap('publish_contacts');
     $role->add_cap('read_contact');
     $role->add_cap('delete_contact');
     unset($role);
 }
开发者ID:Emran04,项目名称:CRM,代码行数:36,代码来源:ecrm.php

示例7: sbscrbr_init

 function sbscrbr_init()
 {
     global $sbscrbr_plugin_info;
     /* load textdomain of plugin */
     load_plugin_textdomain('subscriber', false, dirname(plugin_basename(__FILE__)) . '/languages/');
     require_once dirname(__FILE__) . '/bws_menu/bws_functions.php';
     if (empty($sbscrbr_plugin_info)) {
         if (!function_exists('get_plugin_data')) {
             require_once ABSPATH . 'wp-admin/includes/plugin.php';
         }
         $sbscrbr_plugin_info = get_plugin_data(__FILE__);
     }
     /* check version on WordPress */
     bws_wp_version_check(plugin_basename(__FILE__), $sbscrbr_plugin_info, '3.1');
     /* add new user role */
     $capabilities = array('read' => true, 'edit_posts' => false, 'delete_posts' => false);
     add_role('sbscrbr_subscriber', __('Mail Subscriber', 'subscriber'), $capabilities);
     /* register plugin settings */
     $plugin_pages = array('sbscrbr_settings_page', 'sbscrbr_users');
     if (!is_admin() || isset($_GET['page']) && in_array($_GET['page'], $plugin_pages)) {
         sbscrbr_settings();
     }
     /* unsubscribe users from mailout if Subscribe Form  not displayed on home page */
     if (!is_admin()) {
         sbscrbr_update_user();
     }
 }
开发者ID:axovel,项目名称:tattoo,代码行数:27,代码来源:subscriber.php

示例8: add_role

 private function add_role()
 {
     $roles = self::getRoles();
     foreach ($roles as $id => $name) {
         add_role($id, $name);
     }
 }
开发者ID:konstantin-mohin,项目名称:WordPress,代码行数:7,代码来源:UserRole.php

示例9: sevActivate

function sevActivate()
{
    add_role('unverified', __('Unverfied'));
    update_option('default_role', 'unverified');
    // Flush rewrite rules on activation
    flush_rewrite_rules();
}
开发者ID:janusnic,项目名称:OctoberCMS-Wordpress,代码行数:7,代码来源:simple-email-verification.php

示例10: init

 public static function init()
 {
     // remove all roles (except administrator);
     global $wp_roles;
     foreach ($wp_roles->roles as $role => $value) {
         if ($role == 'administrator') {
             continue;
         }
         remove_role($role);
     }
     // register all roles
     foreach (RoleTaxonomy::getDomains() as $name => $label) {
         // Add new taxonomy, make it hierarchical (like categories)
         $labels = array('name' => _x($label, 'taxonomy general name'), 'singular_name' => _x($label, 'taxonomy singular name'), 'search_items' => __('Search Terms'), 'all_items' => __('All Terms'), 'parent_item' => __('Parent Term'), 'parent_item_colon' => __('Parent Term:'), 'edit_item' => __('Edit Term'), 'update_item' => __('Update Term'), 'add_new_item' => __('Add New Term'), 'new_item_name' => __('New Term'), 'menu_name' => __($label));
         $args = array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => FALSE, 'query_var' => true, 'show_in_menu' => true, 'rewrite' => array('slug' => $name), 'public' => TRUE, 'meta_box_cb' => FALSE);
         register_taxonomy($name, array('itemsc', 'itemmc', 'learnout'), $args);
         // 			add_role ('author_' . $name, 'Author @ ' . $label, array(
         // 				'read'         => true,
         // 				'edit_posts'   => true,
         // 				'delete_posts' => true,
         // 			));
         // prefix "a_" --> author
         add_role('a_' . $name, 'Author @ ' . $label, array("delete_others_pages" => false, "delete_others_posts" => false, "delete_pages" => true, "delete_posts" => true, "delete_private_pages" => true, "delete_private_posts" => true, "delete_published_pages" => true, "delete_published_posts" => true, "edit_others_pages" => false, "edit_others_posts" => true, "edit_pages" => true, "edit_posts" => true, "edit_private_pages" => true, "edit_private_posts" => true, "edit_published_pages" => true, "edit_published_posts" => true, "manage_categories" => true, "manage_links" => true, "moderate_comments" => true, "publish_pages" => false, "publish_posts" => false, "read" => true, "read_private_pages" => true, "read_private_posts" => true, "unfiltered_html" => true, "upload_files" => true, "edit_items" => TRUE, "edit_others_items" => TRUE, "edit_published_items" => TRUE, "edit_private_items" => TRUE, "publish_items" => FALSE, "delete_items" => TRUE, "delete_others_items" => TRUE, "delete_published_items" => TRUE, "delete_private_items" => TRUE, "read_private_items" => TRUE, "edit_item" => TRUE, "delete_item" => TRUE, "read_item" => TRUE, "edit_learnouts" => TRUE, "edit_others_learnouts" => TRUE, "edit_published_learnouts" => TRUE, "edit_private_learnouts" => TRUE, "publish_learnouts" => TRUE, "delete_learnouts" => TRUE, "delete_others_learnouts" => TRUE, "delete_published_learnouts" => TRUE, "delete_private_learnouts" => TRUE, "read_private_learnouts" => TRUE, "edit_learnout" => TRUE, "delete_learnout" => TRUE, "read_learnout" => TRUE, "edit_reviews" => TRUE, "edit_others_reviews" => TRUE, "edit_published_reviews" => TRUE, "edit_private_reviews" => TRUE, "publish_reviews" => TRUE, "delete_reviews" => TRUE, "delete_others_reviews" => TRUE, "delete_published_reviews" => TRUE, "delete_private_reviews" => TRUE, "read_private_reviews" => TRUE, "edit_review" => TRUE, "delete_review" => TRUE, "read_review" => TRUE));
         // prefix "e_" --> editor
         add_role('e_' . $name, 'Editor @ ' . $label, array("delete_others_pages" => true, "delete_others_posts" => true, "delete_pages" => true, "delete_posts" => true, "delete_private_pages" => true, "delete_private_posts" => true, "delete_published_pages" => true, "delete_published_posts" => true, "edit_others_pages" => true, "edit_others_posts" => true, "edit_pages" => true, "edit_posts" => true, "edit_private_pages" => true, "edit_private_posts" => true, "edit_published_pages" => true, "edit_published_posts" => true, "manage_categories" => true, "manage_links" => true, "moderate_comments" => true, "publish_pages" => true, "publish_posts" => true, "read" => true, "read_private_pages" => true, "read_private_posts" => true, "unfiltered_html" => true, "upload_files" => true, "edit_items" => TRUE, "edit_others_items" => TRUE, "edit_published_items" => TRUE, "edit_private_items" => TRUE, "publish_items" => TRUE, "delete_items" => TRUE, "delete_others_items" => TRUE, "delete_published_items" => TRUE, "delete_private_items" => TRUE, "read_private_items" => TRUE, "edit_item" => TRUE, "delete_item" => TRUE, "read_item" => TRUE, "edit_learnouts" => TRUE, "edit_others_learnouts" => TRUE, "edit_published_learnouts" => TRUE, "edit_private_learnouts" => TRUE, "publish_learnouts" => TRUE, "delete_learnouts" => TRUE, "delete_others_learnouts" => TRUE, "delete_published_learnouts" => TRUE, "delete_private_learnouts" => TRUE, "read_private_learnouts" => TRUE, "edit_learnout" => TRUE, "delete_learnout" => TRUE, "read_learnout" => TRUE, "edit_reviews" => TRUE, "edit_others_reviews" => TRUE, "edit_published_reviews" => TRUE, "edit_private_reviews" => TRUE, "publish_reviews" => TRUE, "delete_reviews" => TRUE, "delete_others_reviews" => TRUE, "delete_published_reviews" => TRUE, "delete_private_reviews" => TRUE, "read_private_reviews" => TRUE, "edit_review" => TRUE, "delete_review" => TRUE, "read_review" => TRUE));
     }
     // make sure that there is one current role
     $user = wp_get_current_user();
     $current_role = get_user_meta($user->ID, 'current_role', true);
     if (!in_array($current_role, $user->roles)) {
         if (count($user->roles) > 0) {
             update_user_meta($user->ID, 'current_role', array_values($user->roles)[0]);
         }
     }
 }
开发者ID:andreas-thor,项目名称:eal,代码行数:35,代码来源:class.CLA_RoleTaxonomy.php

示例11: wpaam_add_aamuser_capability

function wpaam_add_aamuser_capability()
{
    //add user roles
    add_role('aam_user', __('AAM User', 'wpaam'), array('read' => true));
    add_role('aam_client', __('AAM Client', 'wpaam'), array('read' => true));
    // gets the user role
    $aamuserrole = get_role('aam_user');
    $aamuserrole->add_cap('create_users');
    $aamuserrole->add_cap('list_users');
    $aamuserrole->add_cap('edit_users');
    $aamuserrole->add_cap('delete_users');
    $aamuserrole->add_cap('publish_product');
    $aamuserrole->add_cap('edit_products');
    $aamuserrole->add_cap('edit_product');
    $aamuserrole->add_cap('delete_product');
    $aamuserrole->add_cap('read_product');
    $aamuserrole->add_cap('publish_quotation');
    $aamuserrole->add_cap('edit_quotations');
    $aamuserrole->add_cap('edit_quotation');
    $aamuserrole->add_cap('delete_quotation');
    $aamuserrole->add_cap('read_quotation');
    $aamuserrole->add_cap('publish_invoice');
    $aamuserrole->add_cap('edit_invoices');
    $aamuserrole->add_cap('edit_invoice');
    $aamuserrole->add_cap('delete_invoice');
    $aamuserrole->add_cap('read_invoice');
    //echo "<pre>"; print_r($aamuserrole); die;
    // This only works, because it accesses the class instance.
}
开发者ID:devd123,项目名称:wpaam,代码行数:29,代码来源:actions.php

示例12: addMissingRoles

 /**
  * Adds back missing author role
  */
 public function addMissingRoles()
 {
     if (!get_role('author')) {
         add_role('author', 'Author', array('upload_files' => true, 'edit_posts' => true, 'edit_published_posts' => true, 'publish_posts' => true, 'read' => true, 'level_2' => true, 'level_1' => true, 'level_0' => true, 'delete_posts' => true, 'delete_published_posts' => true));
         delete_option('_author_role_bkp');
     }
 }
开发者ID:helsingborg-stad,项目名称:Municipio,代码行数:10,代码来源:General.php

示例13: pd_new_roles

function pd_new_roles()
{
    add_role('basic_student', 'Basic Student', array('read'));
    add_role('webinar_student', 'Webinar Student', array('read'));
    add_role('sponsor_member', 'Sponsor Member', array('read'));
    add_role('pds_benefactor', 'PDS Benefactor', array('read'));
}
开发者ID:realbig,项目名称:PL_PEACEFULDRAGON_ROLES,代码行数:7,代码来源:peaceful-dragon-roles.php

示例14: vibe_user_roles

 function vibe_user_roles()
 {
     $teacher_capability = array('delete_posts' => true, 'delete_published_posts' => true, 'edit_posts' => true, 'manage_categories' => true, 'edit_published_posts' => true, 'publish_posts' => true, 'read' => true, 'upload_files' => true, 'unfiltered_html' => true, 'level_1' => true);
     $student_capability = array('read');
     add_role('student', __('Student', 'vibe'), $student_capability);
     add_role('instructor', __('Instructor', 'vibe'), $teacher_capability);
 }
开发者ID:songlequang,项目名称:myclass,代码行数:7,代码来源:register.php

示例15: rpr_activation

 public function rpr_activation()
 {
     global $wp_roles;
     add_role('rpr_unverified', 'Unverified');
     update_option('register_plus_redux_last_activated', RPR_ACTIVATION_REQUIRED);
     add_option('rg_rpr_plugin_do_activation_redirect', true);
 }
开发者ID:bvassmer,项目名称:Register-Plus-Redux,代码行数:7,代码来源:register-plus-redux.php


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