Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- copy this code and past functions.php page.
- /**
- * @author Bashar
- * @param WP_Error $errors
- * @param string $sanitized_user_login
- * @param string $user_email
- * @return WP_Error $errors
- */
- function mh_check_email_provider($errors, $sanitized_user_login, $user_email){
- // Allowed Email provider. Must include extention
- $allowed_provider = array('yahoo.com', 'gmail.com', 'ymail.com', 'live.com', 'msn.com');
- // Get users email provider
- $user_mail_provider = substr($user_email, strpos($user_email, '@')+1);
- // Check if users email provider is allowed
- if(in_array($user_mail_provider, $allowed_provider)){
- // Allowed provider:)
- // Return unchanged $erorrs
- return $errors;
- }
- // Provider not allowed :(
- // Add error code and return
- $errors->add( 'restricted_emial_provider', __( '<strong>ERROR</strong>: We only support ' . implode(', ', $allowed_provider) ) );
- return $errors;
- // That's it
- }
- add_filter('registration_errors', 'mh_check_email_provider', 100, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement