I have added a custom post type “Review”, and a custom role “Reviewer”. The issue is when logged as admin I take review which current author is admin and I want to change author to a Reviewer I have no options in dropdown besides admin. When I change a post whose author is a Reviewer, I have 2 options in dropdown: the current author and admin. Other Reviewers are not visible.
here is a part with capabilities
'capabilities' => array(
'edit_post' => 'edit_review',
'edit_others_posts' => 'edit_others_reviews',
'publish_posts' => 'publish_reviews',
'read_post' => 'read_swpd_review',
'read_private_posts' => 'read_private_reviews',
'delete_post' => 'delete_swpd_review'
),
and setting new role
/* Add guest author role to the blog */
add_role('reviewer', 'Reviewer', array('edit_review','read_review','delete_review'));
//add capabilities for admin
$role_object = get_role( 'administrator' );
$role_object->add_cap( 'read_review' );
$role_object->add_cap( 'edit_review' );
$role_object->add_cap( 'delete_review' );
$role_object->add_cap( 'publish_reviews' );
$role_object->add_cap( 'edit_others_reviews' );
//set level for reviewer (should fix a dropdown bug)
$role_object = get_role( 'reviewer' );
$role_object->add_cap('level_1');
Is it a matter of capabilities? What could be wrong?
The role “Reviewer” only has special capabilities, no other capabilities. To get into the author list you have to be at least a contributor or author.
With this function a reviewer has contributor capabilities plus your special reviewer capabilities. You can change contributor in author to give them also editable powers in the back-end.
Btw you have to run the script only once, preferable in a plugin or functions.php with logged in admin account.
You can check the role by: