How can I run no-disposable-emails plugin when programmatically adding a user with wp_insert_user()?
I mean how does that work?
http://wordpress.org/plugins/no-disposable-email/
$random_password = wp_generate_password( 8, false );
$user_data = array(
'user_login' => $sanitized_user_login,
'user_pass' => wp_generate_password ( 7, false ),
'first_name' => $first_name,
'last_name' => $last_name,
'user_email' => $email,
'display_name' => $first_name . ' ' . $last_name,
'nickname' => $first_name . ' ' . $last_name,
'role' => 'TestDrive',
'city'=>$city,
'state'=>$state,
'country'=>$country
);
$user_id = wp_insert_user($user_data);
HERE what worked for me:
$errors = new WP_Error();
$check_disposable = no_disposable_email($errors, $sanitized_user_login, $email);
$error_string = $check_disposable->get_error_message();
if (!$error_string)) {
$user_id = wp_insert_user($user_data);
} else {
die("Please do not use disposable email for registering!");
}
var-dump($check_disposable);
?