• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_role函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: add_roles

 public function add_roles($roles, $perms)
 {
     $obj = $this;
     add_action('after_setup_theme', function () use($obj, $roles, $perms) {
         //give default capabilties
         $permissions = array();
         foreach ($obj->post_type_capabilities as $key => $value) {
             $permissions[$value] = true;
         }
         //add passed capabilities
         if (!empty($perms)) {
             foreach ($perms as $p) {
                 $permissions[$p] = true;
             }
         }
         if (!empty($roles)) {
             foreach ($roles as $role) {
                 $r = get_role($role);
                 //returns role object
                 foreach ($permissions as $key => $value) {
                     $r->add_cap($key);
                     //adds capabilities (permissions) to role
                 }
             }
         }
     });
 }
开发者ID:sunielsambasivan,项目名称:nommytrips,代码行数:27,代码来源:class-custom-post-type.php


示例17: accesspress_create_role

/**
 * Add our master role, "Premise Member".
 *
 * @since 0.1.0
 */
function accesspress_create_role()
{
    if (get_role('premise_member')) {
        return;
    }
    add_role('premise_member', __('Premise Member', 'premise'), array('access_membership' => true));
}
开发者ID:juslee,项目名称:e27,代码行数:12,代码来源:members.php


示例18: remove_capability

/**
 * Remove existing permissions/capabilities to a specific role
 *
 * @param string $role
 * @param string $cap
 */
function remove_capability($role, $cap)
{
    $role_obj = get_role($role);
    // get the the role object
    $role_obj->remove_cap($cap);
    // add $cap capability to this role object
}
开发者ID:beardon,项目名称:okprop,代码行数:13,代码来源:ingage_useredits.php


示例19: do_activate

 /**
  * Static function for plugin activation.
  *
  * @return void
  */
 public function do_activate()
 {
     global $wp_version;
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     // Check for capability
     if (!current_user_can('activate_plugins')) {
         wp_die(__('Sorry, you do not have suffient permissions to activate this plugin.', MP_DOMAIN));
     }
     // Get the capabilities for the administrator
     $role = get_role('administrator');
     // Must have admin privileges in order to activate.
     if (empty($role)) {
         wp_die(__('Sorry, you must be an Administrator in order to use Manga+Press', MP_DOMAIN));
     }
     if (version_compare($wp_version, '3.0', '<=')) {
         wp_die('Sorry, only WordPress 3.0 and later are supported.' . ' Please upgrade to WordPress 3.0', 'Wrong Version');
     }
     self::$_version = strval(get_option('mangapress_ver'));
     // version_compare will still evaluate against an empty string
     // so we have to tell it not to.
     if (version_compare(self::$_version, MP_VERSION, '<') && !(self::$_version == '')) {
         add_option('mangapress_upgrade', 'yes', '', 'no');
     } elseif (self::$_version == '') {
         add_option('mangapress_ver', MP_VERSION, '', 'no');
         add_option('mangapress_options', serialize(MangaPress_Options::get_default_options()), '', 'no');
     }
     $this->_bootstrap = MangaPress_Bootstrap::get_instance();
     $this->_bootstrap->init();
     $this->after_plugin_activation();
     flush_rewrite_rules(false);
 }
开发者ID:jesgs,项目名称:mangapress,代码行数:36,代码来源:mangapress-install.php


示例20: frontier_post_set_cap

function frontier_post_set_cap()
{
    include FRONTIER_POST_DIR . "/include/frontier_post_defaults.php";
    $fps_saved_capabilities = frontier_post_get_capabilities();
    // Reinstate roles
    $fps_roles = new WP_Roles();
    $role_list = $fps_roles->get_names();
    foreach ($role_list as $key => $item) {
        $xrole = get_role($key);
        $tmp_caplist = $fps_saved_capabilities[$key];
        foreach ($tmp_caplist as $tmp_cap => $tmp_value) {
            $fps_cap_name = $tmp_cap;
            // Check that the name is a capability (not editor or category)
            if (array_key_exists($fps_cap_name, $fp_capability_list) == true) {
                if ($tmp_value == "true") {
                    $xrole->add_cap($tmp_cap);
                } else {
                    $xrole->remove_cap($tmp_cap);
                }
                $xrole->remove_cap('frontier_post_' . $tmp_cap);
            } else {
            }
        }
        // end tmp_caplist
    }
    // end role_list
}
开发者ID:otkinsey,项目名称:wp-nsds,代码行数:27,代码来源:frontier-post-admin-util.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_role_access函数代码示例发布时间:2022-05-15
下一篇:
PHP get_return_value函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap