Replies: 0
I’m trying to limit the capabilities of subsribers. They’re only allowed to make custom posts but there are some things i’m not able to fix.
1. When they make a custom post they cannot edit tags, they can only see them. I want them to be able to edit tags.
2. They can also see the “Post Attributes” window where they can change the post template. I don’t want them to be able to do this.
3. Lastly, subscribers are able to edit things in the “Publish” window, i only want the publish button, not all the other options (visibility, status etc.)
This is my code for handling capabilities :
function add_subscriber_caps() {
// gets the administrator role
$subscriber = get_role( 'subscriber' );
$subscriber->add_cap( 'edit_projects' );
$subscriber->add_cap( 'delete_projects' );
$subscriber->add_cap( 'publish_projects' );
$subscriber->add_cap( 'upload_files' );
$subscriber->remove_cap( 'publish_posts' );
$subscriber->remove_cap( 'edit_posts' );
$subscriber->remove_cap( 'read_posts' );
$subscriber->remove_cap( 'remove_posts' );
$subscriber->remove_cap( 'post-attributes' );
}
add_action( 'admin_init', 'add_subscriber_caps');
function add_admin_caps() {
// gets the administrator role
$admins = get_role( 'administrator' );
$admins->add_cap( 'edit_projects' );
$admins->add_cap( 'edit_projects' );
$admins->add_cap( 'edit_other_projects' );
$admins->add_cap( 'publish_projects' );
$admins->add_cap( 'read_projects' );
$admins->add_cap( 'read_private_projects' );
$admins->add_cap( 'delete_projects' );
}
add_action( 'admin_init', 'add_admin_caps');
I’ve tried using the plugin “User Role Editor”, but it does the exact same thing. Probably because it’s doing the exact same thing as i’m doing in my code…
Does anybody know how to solve these problems?