Assign second role to user

If you first fetch a WP_User object with get_userdata(), you should then be able to add your additional role with the add_role() method, like so: $user = get_userdata($user_id); $user->add_role(‘partner’);

Query users which have same dynamically generated roles as the current user

To achieve this, you first need to get all the current user roles, X and Y(s)… function get_current_user_roles(){ global $wp_roles; $current_user = wp_get_current_user(); $user_groups = groups_get_user_groups( $current_user->ID ); $user_roles = isset( $current_user->roles[‘X’] ) ? array( ‘X’ ) : array(); // Let’s get all Y dynamic user roles… foreach ( $user_groups[‘groups’] as $id ) { $group … Read more

wordpress editor role remove all but ‘menus’ in appearance menu

by default the editor role should not have access to plugins nor appearance menu. But maybe this roles is already customised in your installation? here is a list of editor default capabilities via functions.php you can remove everything in the appearance menu like so: $role_object = get_role( ‘editor’ ); $role_object->remove_cap( ‘edit_theme_options’ ); to remove access … Read more

How to allow user to edit post in wordpress

It would seem like the Basic Authentication Plugin is modifying the contributor user role, removing their edit_posts capability. As you need this plugin activated, I see a couple of options Make a new user role with edit-post capabilities Create a new role that has only the capabilities you need it to have. That way you … Read more