Created
July 17, 2015 00:28
-
-
Save brocheafoin/bd258bef8baa62e8ce47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'um_before_new_user_register', 'require_whitelisted_email_for_signup' ); | |
function require_whitelisted_email_for_signup( $args ) { | |
foreach ( [ 'yahoo.com', 'gmail.com', 'hotmail.com' ] as $domain ) { | |
if ( str_ends_with( $args['user_email'], '@' . $domain ) ) { | |
return true; | |
} | |
} | |
exit( wp_safe_redirect( add_query_arg( 'err', 'blocked_domain' ) ) ); | |
} | |
function str_ends_with( $haystack, $needle ) { | |
return ( strripos( $haystack, $needle, - 1 ) === ( strlen( $haystack ) - strlen( $needle ) ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment