Skip to content

Instantly share code, notes, and snippets.

@ultimatemember
Last active October 25, 2018 01:50
Show Gist options
  • Save ultimatemember/5f093ac300baa1d2a5f1 to your computer and use it in GitHub Desktop.
Save ultimatemember/5f093ac300baa1d2a5f1 to your computer and use it in GitHub Desktop.
Example: block any registration that does not use @gmail as mail provider
/*
The following code will require @gmail.com as domain
for user registrations.
You can change @gmail.com to any provider you want.
The code below requires a user email to be collected during registration
*/
add_action('um_before_new_user_register', 'require_google_email_for_signup');
function require_google_email_for_signup( $args ) {
extract($args);
if ( !strstr( $user_email, '@gmail.com' ) )
exit( wp_redirect( add_query_arg('err', 'you_must_have_googlemail') ) );
}
@jackmoody11
Copy link

Also, how can the error message for this be changed and which file should that code be placed in? I thought I was supposed to edit one of the cases for $err (in the um-actions-misc.php file), but I am breaking the code when I do it.

@ngspear
Copy link

ngspear commented Jul 7, 2017

Hey @jackmoody11 - were you ever able to figure this out? I have the same questions when I'm trying to restrict to only a specific top level domain.

@camilolunacom
Copy link

‘um_before_new_user_register’ has been depreciated, is it possible to ha ave an update version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment