Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ideadude/dead5a70b54d5812bce313b33e0c147f to your computer and use it in GitHub Desktop.
Save ideadude/dead5a70b54d5812bce313b33e0c147f to your computer and use it in GitHub Desktop.
Stop users from setting their username to an email address with Paid Memberships Pro
/*
Stop users from setting their username to an email address
Add this code to a custom plugin.
*/
function pmpro_registration_checks_no_email_user_login($continue) {
//if there are earlier problems, don't bother checking
if(!$continue)
return;
//make sure the username passed in doesn't look like an email address (contains a @)
global $username;
if(!empty($username) && strpos($username, "@") !== false) {
$continue = false;
pmpro_setMessage( 'Your username must not be an email address', 'pmpro_error" );
}
return $continue;
}
add_filter('pmpro_registration_checks', 'pmpro_registration_checks_no_email_user_login');
@travislima
Copy link

Made a change on line 14 where it states:

'pmpro_error" to 'pmpro_error'

Link for reference: https://gist.github.com/travislima/ac1d81cde09eca7f201223cc0a7c0877

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