I am using a WP theme that has a custom post type of 'Vehicle' and a custom user role of 'Seller'.
I am trying to remove the publish vehicle capability for users of the seller role and only allow them to 'Submit for review'** - I have been reading up a lot on this and I tried a plug in called 'WP Role Editor' but this did not work.
I also tried putting this code into my functions file but this is still having no effect whatsoever.
$role = get_role('seller');
$role->remove_cap('publish_posts', false);
Is there a way around this, I have tried a few different code snippets from various websites but none of them seem to do the trick. Your input will be greatly appreciated.
Information when doing var_dump($role)
object(WP_Role)#464 (2) {
["name"]= string(6) "seller"
["capabilities"]= array(20) {
["read"]= bool(true)
["upload_files"]= bool(true)
["assign_seek_terms"]= bool(true)
["create_product"]= bool(true)
["edit_post"]= bool(true)
["edit_gallery_group_post"]= bool(true)
["edit_download_group_post"]= bool(true)
["edit_seek_post"] = bool(false)
["read_seek_post"]= bool(false)
["delete_seek_post"] = bool(false)
["edit_seek_posts"] = bool(true)
["edit_others_seek_posts"] = bool(false)
["publish_seek_posts"] = bool(true)
["read_private_seek_posts"] = bool(false)
["delete_seek_posts"] = bool(true)
["delete_private_seek_posts"] = bool(false)
["delete_published_seek_posts"] = bool(true)
["delete_others_seek_posts"] = bool(false)
["edit_private_seek_posts"]= bool(false)
["edit_published_seek_posts"]= bool(true)
}
}
Edit:
Looking at your var_dump data, 'seller' doesn't have 'publish_posts' to begin with and therefore it cannot be removed!
Test this:
global $wp_roles;
$wp_roles->remove_cap( 'seller', 'publish_posts' );