Support » Plugins and Hacks » Hacks » New users does not get new capabilities

New users does not get new capabilities

  • 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(
    	$centro_cap = array(
    	$docente_cap = array(
    	$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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’ve just installed the plugin User Role Editor and with my surprise my new roles doesn’t have any of the capabilities I’ve specified inside my functions.php

    Is something strange because as seen from this image the WP system is saving the id of my capabilities inside the array… there’s something that I am missing??

    Did you edit the code, or paste it exactly as it is? What happens if you delete the ‘ifp_role_set’ option so that the code re-runs?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘New users does not get new capabilities’ is closed to new replies.