If it's supposed to edit its own post only, make it with author's capabilities. If it should edit posts of other users, as well, make it with editor's capabilities.
Case 1
function wpse_add_your_role() {
$role = get_role( 'author' );
if ( ! empty( get_role( 'your_role' ) ) ) {
remove_role( 'your_role' );
}
add_role( 'your_role', 'Your Role', $role->capabilities );
}
add_action( 'init', 'wpse_add_your_role', 10 );
Case 2
function wpse_add_your_role() {
$role = get_role( 'editor' );
if ( ! empty( get_role( 'your_role' ) ) ) {
remove_role( 'your_role' );
}
add_role( 'your_role', 'Your Role', $role->capabilities );
}
add_action( 'init', 'wpse_add_your_role', 10 );
Code location
In both cases, put the code in current theme's functions.php
file. Once the new role is created, remove the code from functions.php
, or comment out this line:
// add_action( 'init', 'wpse_add_your_role', 10 );
Final notes
You can fine tune your role, using $role->add_cap()
or $role->remove_cap()
methods, according to your needs. In case 1, do not remove edit_posts
capability. In case 2, do not remove, neither, edit_posts
nor edit_others_posts
capabilities.