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


PHP get_role函数代码示例

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


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

示例1: wuw_deactivate

function wuw_deactivate()
{
    $admin_role = get_role('administrator');
    if ($admin_role->has_cap('whats_up_wordpress') === true) {
        $admin_role->remove_cap('whats_up_wordpress');
    }
}
开发者ID:jamesdimick,项目名称:whats-up-wordpress-plugin,代码行数:7,代码来源:whats-up-wordpress.php

示例2: members_user_has_cap_filter

/**
 * Filter on `user_has_cap` to explicitly deny caps if there are conflicting caps when a
 * user has multiple roles.  WordPress doesn't consistently handle two or more roles that
 * have the same capability but a conflict between being granted or denied.  Core WP
 * merges the role caps so that the last role the user has will take precedence.  This
 * has the potential for granting permission for things that a user shouldn't have
 * permission to do.
 *
 * @since  1.0.0
 * @access public
 * @param  array  $allcaps
 * @param  array  $caps
 * @param  array  $args
 * @param  object $user
 * @return array
 */
function members_user_has_cap_filter($allcaps, $caps, $args, $user)
{
    // If the user doesn't have more than one role, bail.
    if (1 >= count((array) $user->roles)) {
        return $allcaps;
    }
    // Get the denied caps.
    $denied_caps = array_keys($allcaps, false);
    // Loop through the user's roles and find any denied caps.
    foreach ((array) $user->roles as $role) {
        // Get the role object.
        $role_obj = get_role($role);
        // If we have an object, merge it's denied caps.
        if (!is_null($role_obj)) {
            $denied_caps = array_merge($denied_caps, array_keys($role_obj->capabilities, false));
        }
    }
    // If there are any denied caps, make sure they take precedence.
    if ($denied_caps) {
        foreach ($denied_caps as $denied_cap) {
            $allcaps[$denied_cap] = false;
        }
    }
    // Return all the user caps.
    return $allcaps;
}
开发者ID:gecugamo,项目名称:customledgers,代码行数:42,代码来源:functions-users.php

示例3: removeCustomCapability

 /**
  * Remove custom user capability to a given role.
  *
  * @param $roleKey
  * @param $cap
  *
  * @since 1.0.0
  */
 public function removeCustomCapability($roleKey, $cap)
 {
     do_action('wwp_action_before_remove_custom_cap', $roleKey, $cap);
     $role = get_role($roleKey);
     $role->remove_cap($cap);
     do_action('wwp_action_after_remove_custom_cap', $roleKey, $cap);
 }
开发者ID:sawan34,项目名称:tanzi,代码行数:15,代码来源:class-wwp-wholesale-roles.php

示例4: run_checks

 /**
  * Runs checks for necessary config options.
  *
  * @return void Method does not return.
  */
 public function run_checks()
 {
     $role = get_role('administrator');
     $current_user = get_userdata(get_current_user_id());
     if (!is_object($role) || !is_object($current_user) || !$role->has_cap('manage_ai1ec_options') || defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     global $plugin_page;
     $settings = $this->_registry->get('model.settings');
     $notification = $this->_registry->get('notification.admin');
     $notifications = array();
     // check if is set calendar page
     if (!$settings->get('calendar_page_id')) {
         $msg = Ai1ec_I18n::__('Select an option in the <strong>Calendar page</strong> dropdown list.');
         $notifications[] = $msg;
     }
     if ($plugin_page !== AI1EC_PLUGIN_NAME . '-settings' && !empty($notifications)) {
         if ($current_user->has_cap('manage_ai1ec_options')) {
             $msg = sprintf(Ai1ec_I18n::__('The plugin is installed, but has not been configured. <a href="%s">Click here to set it up now &raquo;</a>'), admin_url(AI1EC_SETTINGS_BASE_URL));
             $notification->store($msg, 'updated', 2, array(Ai1ec_Notification_Admin::RCPT_ADMIN));
         } else {
             $msg = Ai1ec_I18n::__('The plugin is installed, but has not been configured. Please log in as an Administrator to set it up.');
             $notification->store($msg, 'updated', 2, array(Ai1ec_Notification_Admin::RCPT_ALL));
         }
         return;
     }
     foreach ($notifications as $msg) {
         $notification->store($msg, 'updated', 2, array(Ai1ec_Notification_Admin::RCPT_ADMIN));
     }
 }
开发者ID:newmight2015,项目名称:psmpsm,代码行数:35,代码来源:check.php

示例5: __construct

 function __construct()
 {
     add_filter('user_contactmethods', array($this, 'additional_contact_fields'), 10, 1);
     $role = get_role('editor');
     $role->add_cap('edit_theme_options');
     add_action('admin_menu', array($this, 'custom_admin_menu'));
 }
开发者ID:jh1uw,项目名称:uw-2014,代码行数:7,代码来源:class.users.php

示例6: capability_filter

 public function capability_filter($allcaps, $cap, $args)
 {
     $Admin = get_role('admin');
     $Contributor = get_role('contributor');
     $Contributor->add_cap('upload_files');
     return $allcaps;
 }
开发者ID:ActiveWebsite,项目名称:BoojPressPlugins,代码行数:7,代码来源:WpBooj.php

示例7: remove_capabilities

 /**
  * Removes our settings user capabilities
  *
  * @return void
  */
 public function remove_capabilities()
 {
     // Get user role
     $role = get_role('administrator');
     // Remove the capability
     $role->remove_cap('easingslider_manage_settings');
 }
开发者ID:mist-01,项目名称:easing-slider,代码行数:12,代码来源:class-es-settings-page.php

示例8: get_role

 public function get_role($output = 'name')
 {
     if ('object' === $output) {
         return get_role($this->item->roles[0]);
     }
     return $this->item->roles[0];
 }
开发者ID:felixarntz,项目名称:wp-objects,代码行数:7,代码来源:User.php

示例9: wps_admin_bar

function wps_admin_bar()
{
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('wp-logo');
    $wp_admin_bar->remove_menu('about');
    $wp_admin_bar->remove_menu('wporg');
    $wp_admin_bar->remove_menu('documentation');
    $wp_admin_bar->remove_menu('support-forums');
    $wp_admin_bar->remove_menu('feedback');
    $wp_admin_bar->remove_menu('view-site');
    $wp_admin_bar->remove_menu('comments');
    //$wp_admin_bar->remove_menu('new-post');
    $wp_admin_bar->remove_menu('new-media');
    $wp_admin_bar->remove_menu('new-link');
    //check if we're using posts
    $roots_option = roots_get_global_options();
    $show_posts = $roots_option['roots_show_posts'];
    $role = get_role('editor');
    if ($show_posts == 'no') {
        $wp_admin_bar->remove_menu('new-post');
        $role->remove_cap('edit_posts');
    } else {
        $role->add_cap('edit_posts');
    }
}
开发者ID:ndimatteo,项目名称:yas-theme,代码行数:25,代码来源:cleanup.php

示例10: webbird_permissions_gravity_forms

function webbird_permissions_gravity_forms()
{
    $role = get_role('editor');
    $role->add_cap('gform_full_access');
    $role = get_role('shop_manager');
    $role->add_cap('gform_full_access');
}
开发者ID:filipvanreeth,项目名称:stockmans-wp-theme,代码行数:7,代码来源:gravity-forms.php

示例11: removeProcess

 function removeProcess()
 {
     if (is_admin()) {
         $filename = dirname(__FILE__) . DS . 'uninstall.sql';
         $handle = fopen($filename, 'r');
         $query = fread($handle, filesize($filename));
         fclose($handle);
         $modelObj =& WYSIJA::get('user', 'model');
         $queries = str_replace('DROP TABLE `', 'DROP TABLE `[wysija]', $query);
         $queries = explode('-- QUERY ---', $queries);
         $modelWysija = new WYSIJA_model();
         global $wpdb;
         foreach ($queries as $query) {
             $modelWysija->query($query);
         }
         delete_option('wysija');
         WYSIJA::update_option('wysija_reinstall', 1);
         global $wp_roles;
         foreach ($wp_roles->roles as $rolek => $roled) {
             if ($rolek == 'administrator') {
                 continue;
             }
             $role = get_role($rolek);
             $arr = array('wysija_newsletters', 'wysija_subscribers', 'wysija_subscriwidget', 'wysija_config');
             foreach ($arr as $arrkey) {
                 $role->remove_cap($arrkey);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:fwelections,项目名称:fwelections,代码行数:32,代码来源:uninstall.php

示例12: 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

示例13: 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

示例14: create

 /**
  * Create a user
  *
  * @param array $args
  * @param array $assoc_args
  **/
 public function create($args, $assoc_args)
 {
     global $blog_id;
     $user_login = $args[0];
     $user_email = $args[1];
     if (!$user_login || !$user_email) {
         WP_CLI::error("Login and email required (see 'wp user help').");
     }
     $defaults = array('role' => get_option('default_role'), 'user_pass' => wp_generate_password(), 'user_registered' => strftime("%F %T", time()), 'display_name' => false);
     extract(wp_parse_args($assoc_args, $defaults), EXTR_SKIP);
     if ('none' == $role) {
         $role = false;
     } elseif (is_null(get_role($role))) {
         WP_CLI::error("Invalid role.");
     }
     $user_id = wp_insert_user(array('user_email' => $user_email, 'user_login' => $user_login, 'user_pass' => $user_pass, 'user_registered' => $user_registered, 'display_name' => $display_name, 'role' => $role));
     if (is_wp_error($user_id)) {
         WP_CLI::error($user_id);
     } else {
         if (false === $role) {
             delete_user_option($user_id, 'capabilities');
             delete_user_option($user_id, 'user_level');
         }
     }
     WP_CLI::success("Created user {$user_id}.");
 }
开发者ID:bytewang,项目名称:wp-cli,代码行数:32,代码来源:user.php

示例15: stats_load

function stats_load()
{
    Jetpack::enable_module_configurable(__FILE__);
    Jetpack::module_configuration_load(__FILE__, 'stats_configuration_load');
    Jetpack::module_configuration_head(__FILE__, 'stats_configuration_head');
    Jetpack::module_configuration_screen(__FILE__, 'stats_configuration_screen');
    // Generate the tracking code after wp() has queried for posts.
    add_action('template_redirect', 'stats_template_redirect', 1);
    add_action('wp_head', 'stats_admin_bar_head', 100);
    add_action('jetpack_admin_menu', 'stats_admin_menu');
    add_action('wp_dashboard_setup', 'stats_register_dashboard_widget');
    // Tell HQ about changed settings
    add_action('update_option_home', 'stats_update_blog');
    add_action('update_option_siteurl', 'stats_update_blog');
    add_action('update_option_blogname', 'stats_update_blog');
    add_action('update_option_blogdescription', 'stats_update_blog');
    add_action('update_option_timezone_string', 'stats_update_blog');
    add_action('add_option_timezone_string', 'stats_update_blog');
    add_action('update_option_gmt_offset', 'stats_update_blog');
    add_action('update_option_page_on_front', 'stats_update_blog');
    add_action('update_option_permalink_structure', 'stats_update_blog');
    add_action('update_option_category_base', 'stats_update_blog');
    add_action('update_option_tag_base', 'stats_update_blog');
    // Tell HQ about changed posts
    add_action('save_post', 'stats_update_post', 10, 1);
    add_filter('jetpack_xmlrpc_methods', 'stats_xmlrpc_methods');
    foreach (stats_get_option('roles') as $role) {
        $role = get_role($role);
        if ($role) {
            $role->add_cap('view_stats');
        }
    }
}
开发者ID:sajidsan,项目名称:sajidsan.github.io,代码行数:33,代码来源:stats.php


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