hello guys
i got stuck on how to let users edit only my custom post type and not the standard posts
any thoughs how to do so
tnx in advance
hello guys
i got stuck on how to let users edit only my custom post type and not the standard posts
any thoughs how to do so
tnx in advance
When registering custom post_type, you have to supply the capabilities parameter. For example:
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'capabilities' => array('edit_post' => 'edit_testimony',
'edit_posts' => 'edit_testimonies'),
'hierarchical' => false,
'menu_position' => null,
'supports' => array('editor', 'author', 'thumbnail'),
);
The code above sets the capabilities for edit_post and edit_posts to be different from standard 'post'.
Then you can add the capabilities to role that you are targeting (and the admin of course). For example, the following source code adds those capabilities to admin and subscriber roles.
$role = get_role('administrator');
$role->add_cap('edit_testimony');
$role->add_cap('edit_testimonies');
$role = get_role('subscriber');
$role->add_cap('edit_testimony');
$role->add_cap('edit_testimonies');
I found error when working with the editor, logged in as subscriber, when editing other's post. In case you are interested to know, here is the description of the error: https://core.trac.wordpress.org/ticket/14334.
thats really cool
a big tnx dude
This topic has been closed to new replies.