What the plugin you mention does is apply a filter to registration_errors
, which is used by a function called register_new_user
. The quickest and easiest solution would be to use that function instead of wp_insert_user
.
If that isn’t possible or your code design doesn’t allow it, you can always call no_disposable_email
directly, and before wp_insert_user
.
$errors = new WP_Error();
$sanitized_user_login = 'login';
$user_email="[email protected]";
$check_disposable = no_disposable_email($errors, $sanitized_user_login, $user_email);
If (!is_wp_error($check_disposable)) {
// wp_insert_user
} else {
// whatever you need
}
Very bare-bones code sample, but should get you started.