I have be trying this all day but it is not working how do I set a role for the current user I am inserting with the wp_insert_user()
function
$userdata = array(
'user_login' => $username,
'user_email' => $email,
'user_pass' => $password,
'user_url' => $website,
'first_name' => $first_name,
'last_name' => $last_name,
'nickname' => $nickname,
'description' => $bio,
'role' => 'Editor'
);
$user = wp_insert_user( $userdata );
$WP_array = array (
'user_login' => $username,
'user_email' => $email,
'user_pass' => $password,
'user_url' => $website,
'first_name' => $first_name,
'last_name' => $last_name,
'nickname' => $nickname,
'description' => $bio,
) ;
$id = wp_insert_user( $WP_array ) ;
wp_update_user( array ('ID' => $id, 'role' => 'editor') ) ;
Since you are looking for working solutions, this one should work, and it is only the helpful answer candidate. I am ware that this may not be the best solution, maybe not even close, but it should work.