Advertisement
hmbashar

restricted mail from Wordpress

Apr 22nd, 2014
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. copy this code and past functions.php page.
  2. /**
  3.      * @author Bashar
  4.      * @param WP_Error $errors
  5.      * @param string $sanitized_user_login
  6.      * @param string $user_email
  7.      * @return WP_Error $errors
  8.      */
  9.     function mh_check_email_provider($errors, $sanitized_user_login, $user_email){
  10.         // Allowed Email provider. Must include extention
  11.         $allowed_provider = array('yahoo.com', 'gmail.com', 'ymail.com', 'live.com', 'msn.com');
  12.        
  13.         // Get users email provider
  14.         $user_mail_provider = substr($user_email, strpos($user_email, '@')+1);
  15.         // Check if users email provider is allowed
  16.         if(in_array($user_mail_provider, $allowed_provider)){
  17.             // Allowed provider:)
  18.             // Return unchanged $erorrs
  19.             return $errors;
  20.         }
  21.         // Provider not allowed :(
  22.         // Add error code and return
  23.         $errors->add( 'restricted_emial_provider', __( '<strong>ERROR</strong>: We only support ' . implode(', ', $allowed_provider) ) );
  24.         return $errors;
  25.         // That's it
  26.     }
  27.     add_filter('registration_errors', 'mh_check_email_provider', 100, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement