Hi all,
I am developing a new theme and I need to create some new roles and set them tiwh some capabilities. So I started to edit my functions.php and I added this code:
function controllo_utenti(){
global $wp_roles;
$studente_cap = array(
'read',
'read_private_pages',
'read_private_posts',
'studente'
);
$centro_cap = array(
'delete_posts',
'delete_published_posts',
'edit_post',
'edit_posts',
'edit_published_posts',
'publish_posts',
'read',
'read_private_pages',
'read_private_posts',
'centro'
);
$docente_cap = array(
'read',
'read_private_pages',
'read_private_posts',
'docente'
);
$roles_set = get_option('ifp_role_set');
if( !$roles_set){
add_role( 'studente', 'Studente', $studente_cap);
add_role( 'centro', 'Centro', $centro_cap );
add_role( 'docente', 'Docente', $docente_cap );
update_option( 'ifp_role_set', true );
}
}
add_action( 'after_setup_theme', 'controllo_utenti');
For the time beign everythings is working just fine, as I check the capabilities of each role I can see the all setted up.
But when I register a new user and I set it to one of the roles, the brand new role does not have other capabilities than the name of the new role.
To set the new role I am using this string:
wp_update_user( array ('ID' => $user_id, 'role' => $posted['your_role'] ) ) ;
Maybe I missunderstood something but, when I give a role to a new user is it supposed to inherit the capabilities of that role?
Does anyone have an idea about how solve this issue?
Thanks in advance for your answers!