Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brocheafoin/bd258bef8baa62e8ce47 to your computer and use it in GitHub Desktop.
Save brocheafoin/bd258bef8baa62e8ce47 to your computer and use it in GitHub Desktop.
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