• Hi there,
    I’ve been reading this forum looking for a solution to my problem (as topic) and the most helpul thing I found is this thread.

    Unfortunately is closed! And I would like to understand how the sanitize_meta() has been modified and why I cannot set my roles from there… I think I must use update_user_option() instead…

    Do you have better ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • My bad, user option is not right…

    I’ve tried with the method set_role() but either that is working…

    Some code from a thread found in this forum…

    $user_id_role = new WP_User( $user_id );
    $user_id_role->set_role('Publisher');

    I hope you know a better one, maybe update_user_meta()? Can it modify the role??

    $WP_array = array (
    		//'ID' => $a['members_id'],
    		'user_pass' => $a['members_password'],
    		'user_login' => $a['members_username'],
    		'user_nicename' => $a['members_username'],
    		'user_email' => $a['members_email'],
    		'display_name' => $a['members_username'],
    		'nickname' => $a['members_username'],
    		'first_name' => $a['members_firstname'],
    		'last_name' => $a['members_lastname'],
    		'description' => 'This user was imported',
    	) ;
    
    	$id = wp_insert_user( $WP_array ) ;
    
    	wp_update_user( array ('ID' => $id, 'role' => 'affiliate' ) ) ;

    Worked for me…. Note that even though the role is called Affiliates it was actually affiliate in the list of roles.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_insert_user does not apply to roles!’ is closed to new replies.