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

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/

How to change a user’s role?

See the WP_User class, you can use this to add and remove roles for a user. EDIT: I really should have provided more information with this answer initially, so i’m adding more information below. More specifically, a user’s role can be set by creating an instance of the WP_user class, and calling the add_role() or … Read more

allow editors to edit menus?

add this to your theme’s functions.php: // add editor the privilege to edit theme // get the the role object $role_object = get_role( ‘editor’ ); // add $cap capability to this role object $role_object->add_cap( ‘edit_theme_options’ ); Update (suggested in comments): You probably shouldn’t do this on every request, AFAIK this causes a db write. Better … Read more