Administrator role capabilities

you’re creating a function and just initializing a local scope variable that you overwrite it. here is a different approach: global $wp_roles; // global class wp-includes/capabilities.php $wp_roles->remove_cap( ‘administrator’, ‘manage_options’ ); _based on codex:remove_cap_ Edit: /** * Remove capability from admins. */ function wpcodex_set_capabilities() { // Get the role object. $admin = get_role( ‘administrator’ ); $admin->remove_cap( … Read more

Assign multiple roles , overlapping capabilities

I am pretty sure that nothing would happen other than the user would have the capability in question. Think about it. The default Roles share many capabilities— Authors, Editors, and Administrators all have edit_posts, for example. All roles (usually) have read The same system manages both default and custom roles/capabilities, so there really should be … Read more

Capabilities Not Changing

I believe your code is right. Try going to: ‘wp-admin/users.php’ manually to check if you have the privilege to do so. If my inkling is right, it’s just the $submenu item that is hidden. If you can access the list of users, try printing the global variable $submenu and see if ‘users.php’ is there.

Remove capability from specific user

the page you linked shows how to remove a capability from a role: global $wp_roles; // remove capability $cap from role $role $wp_roles->remove_cap( $role, $cap ); and an example would be: // for example $wp_roles->remove_cap( ‘subscriber’, ‘view_galleries’ ); or remove a capability from a specific user: // get the user by username say for example … Read more

Allow Contributor to edit published post and filter by page id

You can use user_has_cap filter to check and grant capabilities dynamically. add_filter(‘user_has_cap’, ‘contributor_can_edit_published_posts’, 10, 4); function contributor_can_edit_published_posts($allcaps, $caps, $args, $user) { global $post; // Do we have a post? if ( ! $post ) { return $allcaps; } // Is the user a contributor? if ( ! isset( $allcaps[‘contributor’] ) || true !== $allcaps[‘contributor’] ) … Read more