Multiple Authors on Single Post

I want to throw this out there as an answer to the question. I have stumbled across a plugin that will take WordPress’s permissions to the next level. It is called Press Permit. http://presspermit.com/extensions/pp-collaborative-editing/ Taken from Press Permit FAQ’s: How does Press Permit compare to Capability Manager, User Role Editor and other role editor plugins? … Read more

Check whether user can delete a given post

After hours of fighting to get this to work, it was just a matter of changing delete_posts to delete_post. So, in it’s entirety this would be: current_user_can(‘delete_posts’, $post_id); to current_user_can(‘delete_post’, $post_id); current_user_can does accept a second parameter. Though it’s weird that the function declaration in capabilities.php does not define a second parameter as pointed out … Read more

How can I prevent a writer from being able to edit an article that has been scheduled?

Me, like @fischi think that filter ‘user_has_cap’ is the best choiche for the pourpose, however, I think that is better to the work, regardless the $_GET post or action: WordPress check the meta cabability on a per-post basis, using an additional argument. In few words, when filtering ‘user_has_cap’ for a meta capability (see https://codex.wordpress.org/Function_Reference/map_meta_cap) we … Read more

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

Listing all capabilities in dropdown is returning boolean

Solved with this Answer at Stack Overflow. Each Array Key was the actual name of the capability […] You were searching for the capabilities by name, and since you were only seeing 1s in the output, I figured what you were looking for was in the keys. foreach($capslist as $cap=>$caps){ $dropdown .= ‘<option value=”‘.$cap.'”>’.$cap.'</option>’; }

current_user_can( ‘edit_post’, $post_id ) does not work for contributer but for administrator

using map_meta_cap I added edit_post per post cap to user function my_map_meta_cap( $caps, $cap, $user_id, $args ){ if ( ‘edit_post’ == $cap ) { $post = get_post( $args[0] ); $post_type = get_post_type_object( $post->post_type ); $caps = array(); if ( $user_id == $post->post_author ) $caps[] = $post_type->cap->edit_posts; else $caps[] = $post_type->cap->edit_others_posts; } return $caps; } add_filter( … Read more