Forked from ideadude/pmpro_registration_checks_no_email_user_login.php
Created
January 12, 2018 12:37
-
-
Save travislima/ac1d81cde09eca7f201223cc0a7c0877 to your computer and use it in GitHub Desktop.
Stop users from setting their username to an email address with Paid Memberships Pro
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
/* | |
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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe is included in the blog post on "Prevent users from using an email address as their username." at Paid Memberships Pro here: https://www.paidmembershipspro.com/prevent-users-from-using-an-email-address-as-username/