add_cap only adding the first two in array

Looking at your code I think you are trying to modify the capabilities of existent roles. Am I right? To do that you have to run the add_cap for a role object, not for a user object. Also, you must know that add_cap only accept one capability as string: $role = get_role( ‘editor’ ); $role->add_cap( … Read more

What are the differences in capabilities between the super-administrator and administrator?

The super_admin has access to all admininstrator APIs and also the multi-site functions. If you go to the codex page, it will say so: http://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table You can find the multisite functions here: http://codex.wordpress.org/Function_Reference#Multisite_functions If you want to do a more fine-grain investigation of what it can call, I suggest you get familiar with the WP … Read more

How to restrict specific post types from being read or added by specific user roles (eg. author)?

For the solution to your question, In the register_post_type arguments, use the capability_type parameter & then grant the specific capabilities to the users. For instance, if you set ‘capability_type’ => ‘supplier’, grant the edit_supplier capability to all administrators only More Details capabilities takes an array of the capabilities in the format ‘edit_post’ => ‘edit_supplier’ This … Read more

Can’t use /wp-json/wp/v2/plugins API endpoint even as administrator

SUGGESTIONS I suggest the following: first ensure you are running WordPress version 5.5.* as this version adds the endpoints for /wp/v2/plugins see: New and modified REST API endpoints in WordPress 5.5 using basic authentication issue a request as per the following using curl curl –user username:password https://example.com/wp-json The first request should succeed regardless because it … Read more

Shold I manually add ‘cap’ to admin role ?

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 … Read more

How-to Delay The Capability To Publish Posts?

There won’t be a plugin for that, so I wrote one. You can use it as plugin or (better) a mu-plugin (place it in your ~/wp-content/mu-plugins folder). Mu-Plugin: delay the possibility to “publish a post” by removing the MetaBox For a detailed explanation of what happens and why it happens, please refer to the inline … Read more

Email notification for editors only

Use get_users() function. Reference function notify_editors( $post_id ) { $post = get_post( $post_id ); // Get all editors $editors = get_users( [ ‘role__in’ => [ ‘editor’] ] ); foreach ( $editors as $editor ) { // Setup email $subject = “Post Published: ” . $post->post_title; $message=” Hi ” . $editor->display_name . ‘, Your post, “‘ … Read more