Tag Info

Hot answers tagged

3

A new capability has to be explicitly added to either a role or a user. In your case if you want all administrators to have 'cap' capability you will add it to 'administrator' role: $role = get_role( 'administrator' ); $role->add_cap( 'cap' ); If you want a specific administrator only to have 'cap' capability then you add it to this particular user: ...


2

The plugin you mentioned is only reportedly tested up to WordPress version 3.6.1. I would not (in general) recommend abandoned plugins, because they might impose security risks. Additionally it uses PHP4 class constructors, that might soon be deprecated and it calls non static methods in a static way. If you remove the plugin, you should be able to use ...


1

You can try the map_meta_cap filter: /** * Uneditable posts/pages for editors */ add_filter( 'map_meta_cap', function ( $caps, $cap, $user_id, $args ) { // Edit to your needs: $post_ids = [123, 234, 345, 456]; // Uneditable posts $role = 'editor'; // Uneditable by this user role // Make given posts uneditable for the ...


1

How can I make the contributor rank able to publish an article but have it then require the approval of an admin before it actually gets published to the website? The "Contributor" role already behaves that way: Contributor delete_posts edit_posts read https://codex.wordpress.org/Roles_and_Capabilities#Contributor As you ...


1

Just note that there is a simpler way to change the user role which is especially helpful when you do not know the current role of the user: ->set_role() Example: // Fetch the WP_User object of our user. $u = new WP_User( 3 ); // Replace the current role with 'editor' role $u->set_role( 'editor' );



Only top voted, non community-wiki answers of a minimum length are eligible