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
}
 public static function get_all_wp_roles()
 {
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     return $wp_roles->get_names();
 }
Esempio n. 3
0
 public function wp_roles()
 {
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $return = $wp_roles->get_names();
     return $return;
 }
function cab_get_roles()
{
    global $wp_roles;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->get_names();
    return $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);
}
 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;
 }
 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;
 }
Esempio n. 8
0
 /**
  * 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);
 }
 /**
  * Returns default options
  *
  * @since 6.3
  * @access public
  *
  * @return array Default options
  */
 public static function default_options()
 {
     global $wp_roles;
     if (empty($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $options = array();
     foreach ($wp_roles->get_names() as $role => $label) {
         if ('pending' != $role) {
             $options[$role] = array('login_type' => 'default', 'login_url' => '', 'logout_type' => 'default', 'logout_url' => '');
         }
     }
     return $options;
 }
Esempio n. 10
0
 /**
  * Returns default options
  *
  * @since 6.3
  * @access public
  *
  * @return array Default options
  */
 public static function default_options()
 {
     global $wp_roles;
     if (empty($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $options = array();
     foreach ($wp_roles->get_names() as $role => $label) {
         if ('pending' != $role) {
             $options[$role] = array('theme_profile' => true, 'restrict_admin' => false);
         }
     }
     return $options;
 }
Esempio n. 11
0
 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);
         }
     }
 }
Esempio n. 12
0
 /**
  * Returns default options
  *
  * @since 6.3
  * @access public
  *
  * @return array Default options
  */
 public static function default_options()
 {
     global $wp_roles;
     if (empty($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $options = array();
     foreach ($wp_roles->get_names() as $role => $role_name) {
         if ('pending' != $role) {
             $options[$role] = array(array('title' => __('Dashboard', 'theme-my-login'), 'url' => admin_url()), array('title' => __('Profile', 'theme-my-login'), 'url' => admin_url('profile.php')));
         }
     }
     return $options;
 }
 public function add_caps()
 {
     if ($this->users_settings) {
         return;
     }
     global $wp_roles;
     if (!isset($wp_roles) || !is_object($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $wpcf_capabilities = array_keys(self::wpcf_get_capabilities());
     $roles = $wp_roles->get_names();
     foreach ($roles as $current_role => $role_name) {
         $capability_can = apply_filters('wpcf_capability_can', 'manage_options');
         if (isset($wp_roles->roles[$current_role]['capabilities'][$capability_can])) {
             $role = get_role($current_role);
             if (isset($role) && is_object($role)) {
                 for ($i = 0, $caps_limit = count($wpcf_capabilities); $i < $caps_limit; $i++) {
                     if (!isset($wp_roles->roles[$current_role]['capabilities'][$wpcf_capabilities[$i]])) {
                         $role->add_cap($wpcf_capabilities[$i]);
                     }
                 }
             }
         }
     }
     //Set new caps for all Super Admins
     $super_admins = get_super_admins();
     foreach ($super_admins as $admin) {
         $updated_current_user = new WP_User($admin);
         for ($i = 0, $caps_limit = count($wpcf_capabilities); $i < $caps_limit; $i++) {
             $updated_current_user->add_cap($wpcf_capabilities[$i]);
         }
     }
     // We need to refresh $current_user caps to display the entire NNN menu
     // If $current_user has not been updated yet with the new capabilities,
     global $current_user;
     if (isset($current_user) && isset($current_user->ID)) {
         // Insert the capabilities for the current execution
         $updated_current_user = new WP_User($current_user->ID);
         for ($i = 0, $caps_limit = count($wpcf_capabilities); $i < $caps_limit; $i++) {
             if ($updated_current_user->has_cap($wpcf_capabilities[$i])) {
                 $current_user->add_cap($wpcf_capabilities[$i]);
             }
         }
         // Refresh $current_user->allcaps
         $current_user->get_role_caps();
     }
     $this->users_settings = true;
     update_option(self::$users_settings_name, $this->users_settings);
 }
Esempio n. 14
0
function rbhn_capabilities_clean_up( ) {

    global $wp_roles;
 
    if ( ! isset( $wp_roles ) )
        $wp_roles = new WP_Roles( );
            
    $roles = $wp_roles->get_names( );

    // loop through the roles to create the capability list that needs to be cleaned out
	foreach( $roles as $role_key=>$role_name ) 
    {
        rbhn_role_caps_uninstall( $role_key );
    }
}
Esempio n. 15
0
 function set_permissions()
 {
     $wp_roles = new WP_Roles();
     $all_roles = $wp_roles->get_names();
     foreach ($all_roles as $role => $name) {
         $role_object = get_role($role);
         foreach ($this->permissions as $cap => $grant) {
             if ($cap == 'publish_wiki_pages' && $role == 'wiki_editor') {
                 continue;
             } else {
                 $role_object->add_cap($cap);
             }
         }
     }
 }
Esempio n. 16
0
 public function MPSLRolesSettingsFields()
 {
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $disabledRoles = get_option('mpsl-disabled-roles', array());
     $roles = $wp_roles->get_names();
     unset($roles['administrator']);
     foreach ($roles as $role => $roleName) {
         $checked = '';
         if (in_array($role, $disabledRoles)) {
             $checked = 'checked="checked"';
         }
         echo '<label><input type="checkbox" name="disabled_roles[]" value="' . $role . '" ' . $checked . ' /> ' . $roleName . '</label><br/>';
     }
     echo '<p class="description">' . __('Hide Slider menu for selected groups', MPSL_TEXTDOMAIN) . '</p>';
 }
Esempio n. 17
0
function userpro_rd_get_roles()
{
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->get_names();
    foreach ($roles as $k => $v) {
        ?>
			<option value="<?php 
        echo $k;
        ?>
"><?php 
        echo $v;
        ?>
</option>
			<?php 
    }
}
Esempio n. 18
0
    /**
     * Returns all the settings fields
     *
     * @return array settings fields
     */
    static function get_settings_fields()
    {
        $settings_fields = array();
        global $wp_roles;
        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' => '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 minimum user role who can create projects.', 'cpm'), 'type' => 'multicheck', 'options' => $role_names), array('name' => 'task_start_field', 'label' => __('Task start date', 'cpm'), 'type' => 'checkbox', 'default' => 'off', 'desc' => __('Enable task start date field')), array('name' => 'pagination', 'label' => __('Number of project per page', 'cpm'), 'type' => 'text', 'default' => '10', 'desc' => __('-1 for unlimited', 'cpm')), array('name' => 'logo', 'label' => __('Logo', 'cpm'), 'type' => 'file'), array('name' => 'daily_digest', 'label' => __('Daily Digest', 'cpm'), 'type' => 'checkbox', 'default' => 'on', 'desc' => __('Enable Daily Digest', 'cpm'))));
        $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' => 'new_project_sub', 'label' => __('New Project Subject', 'cpm'), 'default' => 'New Project invitation on %PROJECT_NAME%'), array('name' => 'new_project_body', 'label' => __('New Project Body', 'cpm'), 'type' => 'textarea', 'default' => "Hello\n\nYou are assigned in a new project \"%PROJECT_NAME%\" on %SITE%\nYou can see the project by going here: %PROJECT_URL%", 'desc' => 'use: %SITE%, %PROJECT_NAME%, %PROJECT_DETAILS%, %PROJECT_URL%'), array('name' => 'update_project_sub', 'label' => __('Update Project Subject', 'cpm'), 'default' => 'Update Project invitation on %PROJECT_NAME%'), array('name' => 'update_project_body', 'label' => __('Update Project Body', 'cpm'), 'type' => 'textarea', 'default' => "Hello\n\nYou are assigned in a project update \"%PROJECT_NAME%\" on %SITE%\nYou can see the project by going here: %PROJECT_URL%", 'desc' => 'use: %SITE%, %PROJECT_NAME%, %PROJECT_DETAILS%, %PROJECT_URL%'), array('name' => 'new_message_sub', 'label' => __('New Message Subject', 'cpm'), 'default' => '[%SITE%] New message on project: %PROJECT_NAME%'), array('name' => 'new_message_body', 'label' => __('New Message Body', 'cpm'), 'type' => 'textarea', 'default' => "Author : %AUTHOR%\nPermalink : %MESSAGE_URL%\nMessage : %MESSAGE%", 'desc' => 'use: %SITE%, %AUTHOR%, %AUTHOR_EMAIL%, %PROJECT_NAME%, %PROJECT_URL%, %MESSAGE_URL%, %MESSAGE%, %IP%'), array('name' => 'new_comment_sub', 'label' => __('New Comment Subject', 'cpm'), 'default' => '[%SITE%][%PROJECT_NAME%] New comment added'), array('name' => 'new_comment_body', 'label' => __('Body', 'cpm'), 'type' => 'textarea', 'default' => "Author : %AUTHOR%\nPermalink : %COMMENT_URL%\nComment : %COMMENT%", 'desc' => 'use: %SITE%, %PROJECT_NAME%, %PROJECT_URL%, %AUTHOR%, %AUTHOR_EMAIL%, %COMMENT_URL%, %COMMENT%, %IP%'), array('name' => 'new_task_sub', 'label' => __('New Assigned Task Subject', 'cpm'), 'default' => '[%SITE%][%PROJECT_NAME%] New task assigned to you'), array('name' => 'new_task_body', 'label' => __('Body', 'cpm'), 'type' => 'textarea', 'default' => 'A new task has been assigned to you on %PROJECT_NAME%
Task List URL: %TASKLIST_URL%
Task URL: %TASK_URL%
Task: %TASK%', 'desc' => 'use: %SITE%, %PROJECT_NAME%, %PROJECT_URL%, %AUTHOR%, %AUTHOR_EMAIL%, %TASKLIST_URL%, %TASK_URL%, %TASK%, %IP%'), array('name' => 'complete_task_sub', 'label' => __('Completed Task Subject', 'cpm'), 'default' => '[%SITE%][%PROJECT_NAME%] Completed task'), array('name' => 'completed_task_body', 'label' => __('Body', 'cpm'), 'type' => 'textarea', 'default' => 'A new task has been completed %PROJECT_NAME%
Task List URL: %TASKLIST_URL%
Task URL: %TASK_URL%
Task: %TASK%', 'desc' => 'use: %SITE%, %PROJECT_NAME%, %PROJECT_URL%, %TASKLIST_URL%, %TASK_URL%, %TASK%, %IP%'), 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);
    }
/**
 * Returns all valid roles.
 * The returned list can be translated or not.
 *
 * @uses apply_filters() Calls the 'alkivia_roles_translate' hook on translated roles array.
 * @since 0.5
 *
 * @param boolean $translate If the returned roles have to be translated or not.
 * @return array All defined roles. If translated, the key is the role name and value is the translated role.
 */
function ak_get_roles($translate = false)
{
    global $wp_roles;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->get_names();
    if ($translate) {
        foreach ($roles as $k => $r) {
            $roles[$k] = _x($r, 'User role');
        }
        asort($roles);
        return apply_filters('alkivia_roles_translate', $roles);
    } else {
        $roles = array_keys($roles);
        asort($roles);
        return $roles;
    }
}
 function force_roles_on_free_sites($roles)
 {
     if (!class_exists('ProSites')) {
         return $roles;
     }
     // Doesn't apply if we don't have ProSites
     if (current_user_can('manage_network_options')) {
         return $roles;
     }
     // Doesn't affect Super Admins
     if (!function_exists('is_pro_site')) {
         return $roles;
     }
     // Erm... should never happen.
     $values = get_site_option('wdeb_pro');
     $force = @$values['force_on_free'];
     if (!$force) {
         return $roles;
     }
     // No forcing, nothing to do
     if (is_pro_site()) {
         return $roles;
     }
     // Pro site, no forcing;
     // Force on ALL roles
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $all_roles = array_keys($wp_roles->get_names());
     return array_combine($all_roles, $all_roles);
     /*
     // Just WP default roles...
     return array (
     	'administrator' => 'administrator',
     	'editor' => 'editor',
     	'author' => 'author',
     	'contributor' => 'contributor',
     	'subscriber' => 'subscriber',
     );
     */
 }
Esempio n. 21
0
function userpro_edit_restrict()
{
    global $post;
    echo '<div class="misc-pub-section misc-pub-section-last misc-pub-userpro" style="border-top: 1px solid #eee;">';
    wp_nonce_field(plugin_basename(__FILE__), 'userpro_edit_restrict_nonce');
    $val = get_post_meta($post->ID, '_userpro_edit_restrict', true) ? get_post_meta($post->ID, '_userpro_edit_restrict', true) : 'none';
    echo '<input type="radio" name="userpro_edit_restrict" id="userpro_edit_restrict-none" value="none" ' . checked($val, 'none', false) . ' /> <label for="userpro_edit_restrict-none" class="select-it">' . __('No restriction', 'userpro') . '</label><br />';
    echo '<input type="radio" name="userpro_edit_restrict" id="userpro_edit_restrict-true" value="true" ' . checked($val, 'true', false) . '/> <label for="userpro_edit_restrict-true" class="select-it">' . __('Restricted to All Members', 'userpro') . '</label><br />';
    echo '<input type="radio" name="userpro_edit_restrict" id="userpro_edit_restrict-verified" value="verified" ' . checked($val, 'verified', false) . '/> <label for="userpro_edit_restrict-verified" class="select-it">' . __('Restricted to <b>Verified Accounts</b>', 'userpro') . '</label><br />';
    echo '<input type="radio" name="userpro_edit_restrict" id="userpro_edit_restrict-roles" value="roles" ' . checked($val, 'roles', false) . '/> <label for="userpro_edit_restrict-roles" class="select-it">' . __('Restricted to <b>User Roles</b>', 'userpro') . '</label>';
    ?>
	<p class="restrict_roles"><select name="restrict_roles[]" id="restrict_roles[]" multiple="multiple" class="chosen-select" style="width:300px" data-placeholder="<?php 
    _e('Select roles', 'userpro');
    ?>
">
		<?php 
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->get_names();
    foreach ($roles as $k => $v) {
        ?>
			<option value="<?php 
        echo $k;
        ?>
" <?php 
        userpro_is_selected($k, get_post_meta($post->ID, 'restrict_roles', true));
        ?>
><?php 
        echo $v;
        ?>
</option>
		<?php 
    }
    ?>
	</select></p>
	<?php 
    echo '</div>';
}
Esempio n. 22
0
function wp_roles_checkbox($name, $selected = array())
{
    global $wp_roles;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->get_names();
    foreach ($roles as $role_value => $role_name) {
        if (in_array($role_value, $selected) || $selected[0] == 'all') {
            $checked = 'checked="checked"';
        } else {
            $checked = '';
        }
        echo '<input class="simple" type="checkbox" name="' . $name . '[]" value="' . $role_value . '" ' . $checked . '>' . $role_name . '<br/>';
    }
    if (in_array('guest', $selected) || $selected[0] == 'all') {
        $checked = 'checked="checked"';
    } else {
        $checked = '';
    }
    echo '<input class="simple" type="checkbox" name="' . $name . '[]" value="guest" ' . $checked . '>' . __('Guest', 'useyourdrive');
}
 function create_auto_enter_role_box()
 {
     global $wp_roles;
     /*
     $_roles = array (
     	'administrator' => __('Site Admin'),
     	'editor' => __('Editor'),
     	'author' => __('Author'),
     	'contributor' => __('Contributor'),
     	'subscriber' => __('Subscriber'),
     );
     */
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $_roles = $wp_roles->get_names();
     $roles = $this->_get_option('auto_enter_role');
     $roles = is_array($roles) ? $roles : array();
     foreach ($_roles as $role => $label) {
         $checked = in_array($role, $roles) ? 'checked="checked"' : '';
         echo '' . "<input type='checkbox' name='wdeb[auto_enter_role][{$role}]' id='wdeb-auto_enter_role-{$role}' value='{$role}' {$checked} />" . ' ' . "<label for='wdeb-auto_enter_role-{$role}'>{$label}</label>" . "<br />";
     }
     _e('<p>Users with selected roles will be forced to use the easy mode.</p>', 'wdeb');
 }
Esempio n. 24
0
/**
 * Count number of users who have each of the user roles.
 *
 * Assumes there are neither duplicated nor orphaned capabilities meta_values.
 * Assumes role names are unique phrases.  Same assumption made by WP_User_Search::prepare_query()
 * Using $strategy = 'time' this is CPU-intensive and should handle around 10^7 users.
 * Using $strategy = 'memory' this is memory-intensive and should handle around 10^5 users, but see WP Bug #12257.
 *
 * @since 3.0.0
 * @param string $strategy 'time' or 'memory'
 * @return array Includes a grand total and an array of counts indexed by role strings.
 */
function count_users($strategy = 'time')
{
    global $wpdb, $blog_id, $wp_roles;
    // Initialize
    $id = (int) $blog_id;
    $blog_prefix = $wpdb->get_blog_prefix($id);
    $result = array();
    if ('time' == $strategy) {
        global $wp_roles;
        if (!isset($wp_roles)) {
            $wp_roles = new WP_Roles();
        }
        $avail_roles = $wp_roles->get_names();
        // Build a CPU-intensive query that will return concise information.
        $select_count = array();
        foreach ($avail_roles as $this_role => $name) {
            $select_count[] = "COUNT(NULLIF(`meta_value` LIKE '%" . like_escape($this_role) . "%', FALSE))";
        }
        $select_count = implode(', ', $select_count);
        // Add the meta_value index to the selection list, then run the query.
        $row = $wpdb->get_row("SELECT {$select_count}, COUNT(*) FROM {$wpdb->usermeta} WHERE meta_key = '{$blog_prefix}capabilities'", ARRAY_N);
        // Run the previous loop again to associate results with role names.
        $col = 0;
        $role_counts = array();
        foreach ($avail_roles as $this_role => $name) {
            $count = (int) $row[$col++];
            if ($count > 0) {
                $role_counts[$this_role] = $count;
            }
        }
        // Get the meta_value index from the end of the result set.
        $total_users = (int) $row[$col];
        $result['total_users'] = $total_users;
        $result['avail_roles'] =& $role_counts;
    } else {
        $avail_roles = array();
        $users_of_blog = $wpdb->get_col("SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$blog_prefix}capabilities'");
        foreach ($users_of_blog as $caps_meta) {
            $b_roles = unserialize($caps_meta);
            if (is_array($b_roles)) {
                foreach ($b_roles as $b_role => $val) {
                    if (isset($avail_roles[$b_role])) {
                        $avail_roles[$b_role]++;
                    } else {
                        $avail_roles[$b_role] = 1;
                    }
                }
            }
        }
        $result['total_users'] = count($users_of_blog);
        $result['avail_roles'] =& $avail_roles;
    }
    return $result;
}
 /**
  * Callback for the "Login Required" settings field.
  * This ensure all roles are set to have the connections_view_public
  * capability to ensures all roles can at least view the public entries.
  *
  * @access private
  * @since  0.7.3
  *
  * @param $loginRequired
  *
  * @return int
  */
 public static function setAllowPublic($loginRequired)
 {
     global $wp_roles;
     if ($loginRequired) {
         if (!isset($wp_roles)) {
             $wp_roles = new WP_Roles();
         }
         $roles = $wp_roles->get_names();
         foreach ($roles as $role => $name) {
             cnRole::add($role, 'connections_view_public');
         }
     }
     return $loginRequired;
 }
/**
 * Get user role names
 *
 * @since 2.0
 *
 * @global WP_Roles $wp_roles
 * @return array
 */
function wpuf_get_user_roles()
{
    global $wp_roles;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    return $wp_roles->get_names();
}
Esempio n. 27
0
 /**
  * Get an array of user roles
  *
  * @return array
  */
 public static function get_roles()
 {
     $wp_roles = new WP_Roles();
     $roles = array();
     foreach ($wp_roles->get_names() as $role => $label) {
         $roles[$role] = translate_user_role($label);
     }
     return $roles;
 }
<div class="hrm-update-notification"></div>
<div id="hrm-admin-role"></div>
<?php 
$jk = get_option('pro_test_role');
//hidden form
global $wp_roles;
if (!$wp_roles) {
    $wp_roles = new WP_Roles();
}
//echo '<pre>'; print_r( $wp_roles ); echo '</pre>'; die();
$role_names = $wp_roles->get_names();
$wp_built_in_role = array('administrator', 'editor', 'author', 'contributor', 'subscriber', 'hrm_employee');
$add_permission = hrm_user_can_access($tab, $subtab, 'add') ? true : false;
$delete_permission = hrm_user_can_access($tab, $subtab, 'delete') ? true : false;
$current_user_role = hrm_current_user_role();
foreach ($role_names as $name => $display_name) {
    if ($current_user_role == $name) {
        continue;
    }
    if ($add_permission) {
        $name_id = '<a data-role_name="' . $name . '" data-action="get_role" data-display_name="' . $display_name . '" class="hrm-editable" href="#">' . $name . '</a>';
    } else {
        $name_id = $name;
    }
    $body[] = array($name_id, $display_name);
}
$table['head'] = array('User Role', 'Display Name');
$table['body'] = isset($body) ? $body : array();
$table['td_attr'] = isset($td_attr) ? $td_attr : '';
$table['th_attr'] = array('class="check-column"');
$table['table_attr'] = array('class' => 'widefat');
function frontier_post_admin_page_capabilities()
{
    //must check that the user has the required capability
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    include FRONTIER_POST_DIR . "/include/frontier_post_defaults.php";
    //include("../include/frontier_post_defaults.php");
    echo '<strong>Frontier Post version: ' . FRONTIER_POST_VERSION . '</strong>';
    // ****************************************************************************
    // Save settings
    //*******************************************************************************
    // See if the user has posted us some information
    // If they did, this hidden field will be set to 'Y'
    if (isset($_POST["frontier_isupdated_capabilities_hidden"]) && $_POST["frontier_isupdated_capabilities_hidden"] == 'Y') {
        // ****************************************************************************
        // Update option for capabilities per role
        //*******************************************************************************
        // Do not update capabilities if capabilities are managed externally
        if (!fp_get_option_bool("fps_external_cap")) {
            // Reinstate roles
            $wp_roles = new WP_Roles();
            $roles = $wp_roles->get_names();
            $tmp_cap_list = array_merge($fp_capability_list, $fp_role_option_list);
            $saved_capabilities = frontier_post_get_capabilities();
            foreach ($roles as $key => $item) {
                $xrole = get_role($key);
                $xrole_caps = $xrole->capabilities;
                foreach ($tmp_cap_list as $tmp_cap => $tmp_cap_name) {
                    $tmp_name = $key . '_' . $tmp_cap;
                    $def_value = "false";
                    if ($tmp_cap == 'fps_role_editor_type') {
                        $def_value = "minimal-visual";
                    }
                    if ($tmp_cap == 'fps_role_category_layout') {
                        $def_value = "multi";
                    }
                    if ($tmp_cap == 'fps_role_default_category') {
                        $def_value = get_option("default_category");
                    }
                    if ($tmp_cap == 'fps_role_allowed_categories') {
                        $def_value = '';
                    }
                    if (isset($_POST[$tmp_name])) {
                        $tmp_value = $_POST[$tmp_name] ? $_POST[$tmp_name] : $def_value;
                    } else {
                        $tmp_value = $def_value;
                    }
                    $saved_capabilities[$key][$tmp_cap] = $tmp_value;
                }
                //caps
            }
            // roles
            update_option(FRONTIER_POST_CAPABILITY_OPTION_NAME, $saved_capabilities);
            // Put an settings updated message on the screen
            echo '<div class="updated"><p><strong>' . __("Settings saved.", 'frontier-post') . '</strong></p></div>';
            // Set Wordpress capabilities
            frontier_post_set_cap();
            // Put an settings updated message on the screen
            echo '<div class="updated"><p><strong>' . __("Capabilities set.", 'frontier-post') . '</strong></p></div>';
        }
        // End external managed capabilities
    }
    // end update options
    echo '<div class="wrap">';
    echo '<div class="frontier-admin-menu">';
    echo '<h2>' . __("Frontier Post - Capabilities & Role based settings", "frontier-post") . '</h2>';
    echo '<hr>' . __("Documentation", "frontier_post") . ': <a href="http://wpfrontier.com/frontier-post-profiles-capabilities/" target="_blank">Profiles & Capabilities</a>';
    echo ' - <a href="http://wpfrontier.com/frontier-post-role-based-settings/" target="_blank">Role based settings</a><hr>';
    echo '<form name="frontier_post_settings" method="post" action="">';
    echo '<input type="hidden" name="frontier_isupdated_capabilities_hidden" value="Y">';
    //*****************************************************************************
    // Start capability listing
    //*****************************************************************************
    if (fp_get_option_bool("fps_external_cap")) {
        echo '<i><strong>' . __('Capabilities managed externally', 'frontier-post') . '</strong></i>';
    } else {
        echo '<table border="1" cellspacing="0" cellpadding="0">';
        echo "<tr>";
        echo '<th colspan="16"></center>' . __("Capabilities by user role", "frontier-post") . '</center></th>';
        echo "</tr><tr>";
        echo '<th width="6%">' . __("Role", "frontier-post") . '</th>';
        foreach ($fp_capability_list as $tmp_cap => $tmp_cap_name) {
            echo '<th width="6%">' . $tmp_cap_name . '</th>';
        }
        echo "</tr><tr>";
        global $wp_roles;
        if (!isset($wp_roles)) {
            $wp_roles = new WP_Roles();
        }
        $roles = $wp_roles->get_names();
        $saved_capabilities = frontier_post_get_capabilities();
        // loop through each role
        foreach ($roles as $key => $item) {
            echo '<tr><td>' . $item . '</td>';
            //If Role does not exists, create it in the frontier post array
            if (!array_key_exists($key, $saved_capabilities)) {
                $saved_capabilities[$key] = array();
            }
            $tmp_role_settings = $saved_capabilities[$key];
            if (!is_array($tmp_role_settings)) {
                $tmp_role_settings = array();
            }
            foreach ($fp_capability_list as $tmp_cap => $tmp_cap_name) {
                $tmp_name = $key . '_' . $tmp_cap;
                if (array_key_exists($tmp_cap, $tmp_role_settings)) {
                    $tmp_value = $saved_capabilities[$key][$tmp_cap] ? $saved_capabilities[$key][$tmp_cap] : "false";
                } else {
                    $tmp_value = "false";
                }
                if ($tmp_value == "true") {
                    $tmp_checked = " checked";
                } else {
                    $tmp_checked = " ";
                }
                echo '<td><center>';
                //echo $key."<br>".$tmp_cap."<br>";
                //Hide can_media for subscribers and contributors
                if ($tmp_cap == "frontier_post_can_media" && ($key == "subscriber" || $key == "contributor")) {
                    echo 'N/A';
                } else {
                    echo '<input value="true" type="checkbox" name="' . $tmp_name . '" id="' . $tmp_name . '" ' . $tmp_checked . ' />';
                }
                echo '</center></td>';
            }
            // end cap
            echo '</tr>';
        }
        // end roles
        echo '</table>';
        echo '* ' . __("Wordpress standard does not allow Contributors  and Subscribers to upload media", "frontier-post");
    }
    // endfps_external_cap
    //*****************************************************************************
    // Start Role Based settings
    //*****************************************************************************
    echo '<hr>';
    echo '<table border="1" cellspacing="0" cellpadding="0">';
    echo "<tr>";
    echo '<th colspan="5"></center>' . __("Role based settings", "frontier-post") . '</center></th>';
    echo "</tr><tr>";
    echo '<th width="6%">' . __("Role", "frontier-post") . '</th>';
    foreach ($fp_role_option_list as $tmp_role_option => $tmp_role_option_name) {
        echo '<th width="6%">' . $tmp_role_option_name . '</th>';
    }
    echo "</tr><tr>";
    global $wp_roles;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->get_names();
    $saved_capabilities = frontier_post_get_capabilities();
    $tmp_role_option_list = array_keys($fp_role_option_list);
    // loop through each role
    foreach ($roles as $key => $item) {
        echo '<tr><td>' . $item . '</td>';
        if (!array_key_exists($key, $saved_capabilities)) {
            $saved_capabilities[$key] = array();
        }
        $tmp_role_options = $saved_capabilities[$key];
        if (!is_array($tmp_role_options)) {
            $tmp_role_options = array();
        }
        foreach ($fp_role_option_list as $tmp_role_option => $tmp_role_option_name) {
            $tmp_name = $key . '_' . $tmp_role_option;
            if (array_key_exists($tmp_role_option, $tmp_role_options)) {
                $tmp_value = $saved_capabilities[$key][$tmp_role_option] ? $saved_capabilities[$key][$tmp_role_option] : "false";
            } else {
                $tmp_value = "";
            }
            echo '<td>';
            switch ($tmp_role_option) {
                case 'fps_role_editor_type':
                    $optionlist = array_flip($editor_types);
                    ?>
	
							<select  id="<?php 
                    echo $tmp_name;
                    ?>
" name="<?php 
                    echo $tmp_name;
                    ?>
" >
							<?php 
                    foreach ($optionlist as $id => $desc) {
                        ?>
   
								<option value='<?php 
                        echo $id;
                        ?>
' <?php 
                        echo $id == $tmp_value ? "selected='selected'" : ' ';
                        ?>
>
									<?php 
                        echo $desc;
                        ?>
								</option>
							<?php 
                    }
                    ?>
							</select>
							<?php 
                    break;
                case 'fps_role_category_layout':
                    $optionlist = array_flip($category_types);
                    ?>
	
							<select  id="<?php 
                    echo $tmp_name;
                    ?>
" name="<?php 
                    echo $tmp_name;
                    ?>
" >
							<?php 
                    foreach ($optionlist as $id => $desc) {
                        ?>
   
								<option value='<?php 
                        echo $id;
                        ?>
' <?php 
                        echo $id == $tmp_value ? "selected='selected'" : ' ';
                        ?>
>
									<?php 
                        echo $desc;
                        ?>
								</option>
							<?php 
                    }
                    ?>
							</select>
							<?php 
                    break;
                case 'fps_role_default_category':
                    wp_dropdown_categories(array('id' => $tmp_name, 'hide_empty' => 0, 'name' => $tmp_name, 'orderby' => 'name', 'selected' => $tmp_value, 'hierarchical' => true));
                    break;
                case 'fps_role_allowed_categories':
                    if ($tmp_value == "false") {
                        $tmp_value = "";
                    }
                    echo '<input type="text" name="' . $tmp_name . '" value="' . $tmp_value . '">';
                    break;
            }
            echo '</td>';
        }
        // end option
        echo '</tr>';
    }
    // end roles
    echo '</table>';
    echo '<p class="submit"><input type="submit" name="Submit" class="button-primary" value="' . __('Save Changes') . '"></p>';
    echo '</form>';
    echo '<hr>';
    echo '</div>';
    //frontier-admin-menu
    echo '</div>';
    //wrap
}
 /**
  * Users field callback.
  *
  * @param  array $args Arguments from the option.
  *
  * @return string      Input field HTML.
  */
 public function users_callback($args)
 {
     $id = $args['id'];
     $wp_roles = new WP_Roles();
     $roles = $wp_roles->get_names();
     // Sets current option.
     $current = $this->get_option_value($id, $args['default']);
     $html = sprintf('<select id="%1$s" name="%2$s[%1$s][]" multiple="multiple">', $id, 'notify_users_email');
     foreach ($roles as $role_value => $role_name) {
         $current_item = in_array($role_value, $current) ? ' selected="selected"' : '';
         $html .= sprintf('<option value="%s"%s>%s</option>', $role_value, $current_item, $role_name);
     }
     $html .= '</select>';
     // Displays the description.
     if ($args['description']) {
         $html .= sprintf('<div class="description">%s</div>', $args['description']);
     }
     echo $html;
 }