本文整理汇总了PHP中WP_Roles类的典型用法代码示例。如果您正苦于以下问题:PHP WP_Roles类的具体用法?PHP WP_Roles怎么用?PHP WP_Roles使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WP_Roles类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: check
/**
* given a permission string, check for access requirements
*
* @param string $str the permission to check
*
* @return boolean true if yes, else false
* @access public
*/
function check($str)
{
// Generic cms 'administer users' role tranlates to 'administrator' WordPress role
$str = $this->translatePermission($str, 'WordPress', array('administer users' => 'administrator'));
if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) {
return FALSE;
}
if ($str == CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) {
return TRUE;
}
// for administrators give them all permissions
if (!function_exists('current_user_can')) {
return TRUE;
}
if (current_user_can('super admin') || current_user_can('administrator')) {
return TRUE;
}
// Make string lowercase and convert spaces into underscore
$str = CRM_Utils_String::munge(strtolower($str));
if (is_user_logged_in()) {
// Check whether the logged in user has the capabilitity
if (current_user_can($str)) {
return TRUE;
}
} else {
//check the capabilities of Anonymous user)
$roleObj = new WP_Roles();
if ($roleObj->get_role('anonymous_user') != NULL && array_key_exists($str, $roleObj->get_role('anonymous_user')->capabilities)) {
return TRUE;
}
}
return FALSE;
}
开发者ID:hguru,项目名称:224Civi,代码行数:41,代码来源:WordPress.php
示例3: 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
示例4: add_caps
/**
* 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
示例5: 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
示例6: 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
示例7: handle_rhc_uninstall
function handle_rhc_uninstall()
{
$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->remove_cap(RHC_ADMIN_ROLE, $cap);
}
//-----
}
开发者ID:TheMysticalSock,项目名称:westmichigansymphony,代码行数:8,代码来源:install.php
示例8: wlb_uninstall
function wlb_uninstall()
{
$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->remove_cap(WLB_ADMIN_ROLE, $cap);
}
//-----
}
开发者ID:emjayoh,项目名称:bhag,代码行数:8,代码来源:white-label-branding.php
示例9: get_all_wp_roles
public static function get_all_wp_roles()
{
global $wp_roles;
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
return $wp_roles->get_names();
}
开发者ID:hamednourhani,项目名称:baharloo-appoitment,代码行数:8,代码来源:class_app_roles.php
示例10: wp_roles
public function wp_roles()
{
global $wp_roles;
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
$return = $wp_roles->get_names();
return $return;
}
开发者ID:RCMmedia,项目名称:rubicon,代码行数:9,代码来源:wordpress_user.php
示例11: cab_get_roles
function cab_get_roles()
{
global $wp_roles;
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
$roles = $wp_roles->get_names();
return $roles;
}
开发者ID:tkxhoa,项目名称:movie,代码行数:9,代码来源:custom-admin-bar-functions.php
示例12: user_roles
/**
* 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
示例13: bd_pseudo_role_field_get_available_roles
/**
*
* @global WP_Roles $wp_roles
* @return type
*/
function bd_pseudo_role_field_get_available_roles()
{
global $wp_roles;
if (empty($wp_roles)) {
$wp_roles = new WP_Roles();
}
$all_roles = $wp_roles->get_names();
//all roles as role=>role_name
return apply_filters('bp_pseudo_role_field_roles', $all_roles);
}
开发者ID:buddydev,项目名称:bp-pseudo-role-field,代码行数:15,代码来源:bp-pseudo-role-field-functions.php
示例14: get_role_names
function get_role_names()
{
global $wp_roles;
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
$roles = $wp_roles->get_names();
$roles['guest'] = 'Guest';
return $roles;
}
开发者ID:dss-web,项目名称:erklaringmothatytringer-wp-advance-comment,代码行数:10,代码来源:settings.php
示例15: woocommerce_add_filter_hide_product
public static function woocommerce_add_filter_hide_product($settings)
{
$args = array('post_type' => 'product', 'posts_per_page' => '-1');
$checkproducts = get_posts($args);
if (is_array($checkproducts)) {
foreach ($checkproducts as $product) {
$product_id[] = $product->ID;
$product_title[] = get_the_title($product->ID);
}
}
if (is_array($checkproducts)) {
$newcombinedvalues = array_combine((array) $product_id, (array) $product_title);
}
$get_terms_product = get_terms('product_cat', array('hide_empty' => 'false'));
//var_dump($get_terms_product);
$current_category_products = array();
if (!empty($get_terms_product) && is_array($get_terms_product)) {
foreach ($get_terms_product as $each_term) {
$current_category_products[$each_term->term_id] = $each_term->name;
}
}
//var_dump($current_category_products);
$updated_settings = array();
$mainvariable = array();
foreach ($settings as $section) {
if (isset($section['id']) && '_woo_hide_products_maincontent' == $section['id'] && isset($section['type']) && 'sectionend' == $section['type']) {
global $wp_roles;
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
$getdata = $wp_roles->get_names();
foreach ($getdata as $data => $key) {
$updated_settings[] = array('name' => __('Toggle Shop Products for ' . $key, 'woohideproducts'), 'type' => 'title', 'id' => '_woo_hide_products_' . $data);
$updated_settings[] = array('name' => __('Toggle Type', 'woohideproducts'), 'desc' => __('Toggle Products by category or certain products', 'woohideproducts'), 'tip' => '', 'id' => 'woo_toggle_products_by_type_' . $data, 'css' => '', 'std' => '1', 'defaultvalue' => 'woo_toggle_products_by_type_' . $data, 'type' => 'select', 'options' => array('1' => __('By Products', 'woohideproducts'), '2' => __('By Categories', 'woohideproducts')), 'desc_tip' => true);
$updated_settings[] = array('name' => __('Hide Products in Category', 'woohideproducts'), 'desc' => __('Hide Products in Category Page of WooCommerce', 'woohideproducts'), 'tip' => '', 'id' => 'woo_hide_products_in_category_' . $data, 'css' => '', 'std' => 'yes', 'defaultvalue' => 'woo_hide_products_in_category_' . $data, 'type' => 'checkbox', 'desc_tip' => '');
$updated_settings[] = array('name' => __('Hide Products in Search Result', 'woohideproducts'), 'desc' => __('Hide Products in Search Result of WooCommerce', 'woohideproducts'), 'tip' => '', 'id' => 'woo_hide_products_in_search_' . $data, 'css' => '', 'std' => 'yes', 'defaultvalue' => 'woo_hide_products_in_search_' . $data, 'type' => 'checkbox', 'desc_tip' => '');
$updated_settings[] = array('name' => __('Toggle Include/Exclude Archive Products', 'woohideproducts'), 'desc' => __('Toggle Include Products/Exclude Products in WooCommerce Shop Page', 'woohideproducts'), 'tip' => '', 'id' => 'woo_include_exclude_products_' . $data, 'css' => '', 'std' => '2', 'defaultvalue' => 'woo_include_exclude_products_' . $data, 'type' => 'radio', 'options' => array('1' => __('Include', 'woohideproducts'), '2' => __('Exclude', 'woohideproducts')), 'desc_tip' => true);
$updated_settings[] = array('name' => __('Choose Category', 'woohideproducts'), 'desc' => __('Want to hide products in a bulk way then using this option to hide the products', 'woohideproducts'), 'tip' => '', 'id' => 'woo_toggle_type_category_' . $data, 'css' => '', 'std' => '', 'defaultvalue' => 'woo_toggle_type_category_' . $data, 'type' => 'multiselect', 'options' => $current_category_products);
$updated_settings[] = array('name' => __('Select Product to Toggle Shop', 'woohideproducts'), 'desc' => __('Select Product which will be Toggle Shop in Shop Page', 'woohideproducts'), 'tip' => '', 'id' => 'woo_select_products_' . $data, 'css' => '', 'std' => '', 'type' => 'multiselect', 'options' => $newcombinedvalues);
$updated_settings[] = array('type' => 'sectionend', 'id' => '_woo_hide_products_' . $data);
}
$updated_settings[] = array('name' => __('Toggle Shop Products for Guest', 'woohideproducts'), 'type' => 'title', 'id' => '_woo_hide_products_guest');
$updated_settings[] = array('name' => __('Toggle Type', 'woohideproducts'), 'desc' => __('Toggle Products by category or certain products', 'woohideproducts'), 'tip' => '', 'id' => 'woo_toggle_products_by_type_guest', 'css' => '', 'std' => '1', 'defaultvalue' => 'woo_toggle_products_by_type_guest', 'type' => 'select', 'options' => array('1' => __('By Products', 'woohideproducts'), '2' => __('By Categories', 'woohideproducts')), 'desc_tip' => true);
$updated_settings[] = array('name' => __('Hide Products in Category', 'woohideproducts'), 'desc' => __('Hide Products in Category Page of WooCommerce', 'woohideproducts'), 'tip' => '', 'id' => 'woo_hide_products_in_category_guest', 'css' => '', 'std' => 'yes', 'defaultvalue' => 'woo_hide_products_in_category_guest', 'type' => 'checkbox', 'desc_tip' => '');
$updated_settings[] = array('name' => __('Hide Products in Search Result', 'woohideproducts'), 'desc' => __('Hide Products in Search Result of WooCommerce', 'woohideproducts'), 'tip' => '', 'id' => 'woo_hide_products_in_search_guest', 'css' => '', 'std' => 'yes', 'defaultvalue' => 'woo_hide_products_in_search_guest', 'type' => 'checkbox', 'desc_tip' => '');
$updated_settings[] = array('name' => __('Toggle Include/Exclude Archive Products', 'woohideproducts'), 'desc' => __('Toggle Include Products/Exclude Products in WooCommerce Shop Page', 'woohideproducts'), 'tip' => '', 'id' => 'woo_include_exclude_products_guest', 'css' => '', 'std' => '2', 'defaultvalue' => 'woo_include_exclude_products_guest', 'type' => 'radio', 'options' => array('1' => __('Include', 'woohideproducts'), '2' => __('Exclude', 'woohideproducts')), 'desc_tip' => true);
$updated_settings[] = array('name' => __('Choose Category', 'woohideproducts'), 'desc' => __('Want to hide products in a bulk way then using this option to hide the products', 'woohideproducts'), 'tip' => '', 'id' => 'woo_toggle_type_category_guest', 'css' => '', 'std' => '', 'defaultvalue' => 'woo_toggle_type_category_guest', 'type' => 'multiselect', 'options' => $current_category_products);
$updated_settings[] = array('name' => __('Select Product to Toggle Shop', 'woohideproducts'), 'desc' => __('Select Product which will be Toggle Shop in Shop Page', 'woohideproducts'), 'tip' => '', 'id' => 'woo_select_products_guest', 'css' => '', 'std' => '', 'type' => 'multiselect', 'options' => $newcombinedvalues);
$updated_settings[] = array('type' => 'sectionend', 'id' => '_woo_hide_products_guest');
}
$updated_settings[] = $section;
}
return $updated_settings;
}
开发者ID:Qualitair,项目名称:ecommerce,代码行数:54,代码来源:class-admin-settings.php
示例16: 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
示例17: get_settings_fields
/**
* Returns all the settings fields
*
* @return array settings fields
*/
static function get_settings_fields()
{
global $wp_roles;
$settings_fields = array();
if (!$wp_roles) {
$wp_roles = new WP_Roles();
}
$role_names = $wp_roles->get_names();
$settings_fields['cpm_general'] = apply_filters('cpm_settings_field_general', array(array('name' => 'upload_limit', 'label' => __('File Upload Limit', 'cpm'), 'default' => '2', 'desc' => __('file size in Megabyte. e.g: 2')), array('name' => 'pagination', 'label' => __('Number of project per page', 'cpm'), 'type' => 'text', 'default' => '10', 'desc' => __('-1 for unlimited', 'cpm')), array('name' => 'project_manage_role', 'label' => __('Project Manage Capability', 'cpm'), 'default' => array('editor' => 'editor', 'author' => 'author', 'administrator' => 'administrator'), 'desc' => __('Select the user role who can see and manage all projects', 'cpm'), 'type' => 'multicheck', 'options' => $role_names), array('name' => 'project_create_role', 'label' => __('Project Create Capability', 'cpm'), 'default' => array('editor' => 'editor', 'author' => 'author', 'administrator' => 'administrator'), 'desc' => __('Select the user role who can create projects', 'cpm'), 'type' => 'multicheck', 'options' => $role_names)));
$settings_fields['cpm_mails'] = apply_filters('cpm_settings_field_mail', array(array('name' => 'email_from', 'label' => __('From Email', 'cpm'), 'type' => 'text', 'desc' => '', 'default' => get_option('admin_email')), array('name' => 'email_type', 'label' => __('E-Mail Type', 'cpm'), 'type' => 'select', 'default' => 'text/plain', 'options' => array('text/html' => __('HTML Mail', 'cpm'), 'text/plain' => __('Plain Text', 'cpm'))), array('name' => 'email_bcc_enable', 'label' => __('Send email via Bcc', 'cpm'), 'type' => 'checkbox', 'default' => 'off', 'desc' => __('Enable Bcc'))));
return apply_filters('cpm_settings_fields', $settings_fields);
}
开发者ID:sayfulit,项目名称:wp-project-manager,代码行数:17,代码来源:admin.php
示例18: add
/**
*
* @return type
*/
public function add()
{
$name = trim(aam_Core_Request::post('name'));
$roles = new WP_Roles();
$role_id = 'aamrole_' . uniqid();
if ($roles->add_role($role_id, $name)) {
$response = array('status' => 'success', 'role' => $role_id);
} else {
$response = array('status' => 'failure');
}
return json_encode($response);
}
开发者ID:dot2006,项目名称:jobify,代码行数:16,代码来源:role.php
示例19: add_gf_import_capability
protected function add_gf_import_capability()
{
global $wp_roles;
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
$admin_role = $wp_roles->get_role('administrator');
if (!empty($admin_role) && !$admin_role->has_cap('gravityforms_import')) {
$wp_roles->use_db = true;
// save changes to the database
$admin_role->add_cap('gravityforms_import');
}
}
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:13,代码来源:gf-access.php
示例20: install_capabilities
public function install_capabilities()
{
$roles = $GLOBALS['wp_roles']->roles;
global $wp_roles;
if (!isset($roles)) {
$wp_roles = new WP_Roles();
$roles = $wp_roles->get_names();
}
if (is_array($roles)) {
foreach ($roles as $key => $value) {
$this->add_role_capabilities($key);
}
}
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:14,代码来源:capabilities.php
注:本文中的WP_Roles类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论