Reset default roles and capabilities

I use User Role Editor. You can delete added roles, and reset roles from the plugin page. To reset the administator role, you can, as of WP 3.4+, add define(‘URE_SHOW_ADMIN_ROLE’, 1); to your wp-config.php file. After having done so, you need to go to Users > User Role Editor and click “Reset”.

Remove Ability for Other Users to View Administrator in User List?

Hi @Carlos: Try adding the following to your theme’s functions.php file, or in a .php file within a plugin that you might be writing (which works for WordPress 3.1.x): add_action(‘pre_user_query’,’yoursite_pre_user_query’); function yoursite_pre_user_query($user_search) { $user = wp_get_current_user(); if ($user->ID!=1) { // Is not administrator, remove administrator global $wpdb; $user_search->query_where = str_replace(‘WHERE 1=1’, “WHERE 1=1 AND {$wpdb->users}.ID<>1”,$user_search->query_where); … Read more

How can I get a list of users by their role?

There may be some different way to do that, but most proper way to do that is following. <?php $args = array( ‘role’ => ‘Your desired role goes here.’, ‘orderby’ => ‘user_nicename’, ‘order’ => ‘ASC’ ); $users = get_users( $args ); echo ‘<ul>’; foreach ( $users as $user ) { echo ‘<li>’ . esc_html( $user->display_name … Read more

How to add a Capability to a User Role?

You can use WP_Role class, // get the the role object $role_object = get_role( $role_name ); // add $cap capability to this role object $role_object->add_cap( $capability_name ); // remove $cap capability from this role object $role_object->remove_cap( $capability_name ); So to address your original question about how to enable Admins to enter SCRIPT and IFRAME tags … Read more

Possible to hide Custom Post Type UI/Menu from specific User Roles?

To hide a post type menu item from non-admin users: function wpse28782_remove_menu_items() { if( !current_user_can( ‘administrator’ ) ): remove_menu_page( ‘edit.php?post_type=your_post_type’ ); endif; } add_action( ‘admin_menu’, ‘wpse28782_remove_menu_items’ ); your_post_type should be the name of your actual post type. EDIT- other menu pages you can remove: remove_menu_page(‘edit.php’); // Posts remove_menu_page(‘upload.php’); // Media remove_menu_page(‘link-manager.php’); // Links remove_menu_page(‘edit-comments.php’); // … Read more

How to create a clone role in wordpress

Try this… This should work. <?php add_action(‘init’, ‘cloneRole’); function cloneRole() { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); $adm = $wp_roles->get_role(‘administrator’); //Adding a ‘new_role’ with all admin caps $wp_roles->add_role(‘new_role’, ‘My Custom Role’, $adm->capabilities); } ?> Check it.

Is there way to rename user role name without plugin?

function change_role_name() { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); //You can list all currently available roles like this… //$roles = $wp_roles->get_names(); //print_r($roles); //You can replace “administrator” with any other role “editor”, “author”, “contributor” or “subscriber”… $wp_roles->roles[‘administrator’][‘name’] = ‘Owner’; $wp_roles->role_names[‘administrator’] = ‘Owner’; } add_action(‘init’, ‘change_role_name’); http://www.garyc40.com/2010/04/ultimate-guide-to-roles-and-capabilities/