I use the following code in a frontend form. About 10% of the time, the new user is created as a 'subscriber'. What would cause this erratic behavior?
$new_user_id = wp_insert_user(array( 'role' => 'customer', 'user_login' => $user_login, 'user_pass' => $user_pass, 'user_email' => sanitize_text_field($user_email), 'first_name' => sanitize_text_field($user_first), 'last_name' => sanitize_text_field($user_last), 'user_registered' => date('Y-m-d H:i:s'), ) );
I have also tried
update_user_meta( $new_user_id, 'role', 'customer' ) after the wp_insert_user to catch those that have slipped through, but that does not seem to work.