How to allow editor to edit privacy page / settings only?

Editing the privacy policy page is restricted to manage_privacy_options as pointed out in a comment in the WordPress core file wp-includes/capabilities.php: /* * Setting the privacy policy page requires `manage_privacy_options`, * so editing it should require that too. */ if ( (int) get_option( ‘wp_page_for_privacy_policy’ ) === $post->ID ) { $caps = array_merge( $caps, map_meta_cap( ‘manage_privacy_options’, … Read more

How to get role of user

Use the user ID and WP_User: $user = new WP_User( $user_id ); print wp_sprintf_l( ‘%l’, $user->roles ); Update /** * Get user roles by user ID. * * @param int $id * @return array */ function wpse_58916_user_roles_by_id( $id ) { $user = new WP_User( $id ); if ( empty ( $user->roles ) or ! is_array( … 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

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)