I'm looking for pointers on how to add a capability to a specific user role without using plugins.
For example if I'd like Editors to be able to edit and add users, I thought something like:
function give_user_edit() {
if(current_user_can('edit_others_posts')) {
global $wp_roles;
$wp_roles->add_cap('editor','edit_users' );
$wp_roles->add_cap('editor','create_users' );
}
}
add_action('admin_init', 'give_user_edit', 10, 0);
Would work, but it seemed to add the capabilities for everyone.
Any pointers greatly appreciated.