I want to create dynamic capabilities using WP_Role::add_cap(), something like
$author_role = get_role('author');
foreach ($sections as $section) {
$author_role->add_cap( "edit_{$section}_pages", /* grant= */ false );
}
and then let administrators grant certain of those capabilities to certain authors only (e.g., Jane can edit_school_pages) in wp-admin (not programmatically, via WP_User::add_cap()).
I assume a plugin can help with this, but those I’ve found (e.g., Capability Manager) seem to emphasize creating new Roles or Capabilities and adding/moving Capabilities among Roles, not granting capabilities directly to users (though I could be wrong).
Advice? Thanks, s
you can assign capabilities directly to user using the class
WP_user::add_cap()
Source – https://wordpress.stackexchange.com/a/60433/17968
I there, i’m starting to use this plugin.
I’m editing ’cause was a poor answer. So, the plugin that i’m starting to use is ‘Role Scoper for WordPress‘. I need to have different roles, but, first all, I need to assign right ‘per post’. This plugin seems to do it, with just a little bit trick. I’ll try further more so i’ll can write much better.
Capabilities are permissions for roles. Those roles are then extended to the users, which determines what a user can do. The reason you use roles is to avoid managing permissions per user.
The best way to accomplish what you want is to create a new role for each set of capabilities that you want and assign the user to each role with a member management plugin.