Last active
September 6, 2019 14:45
-
-
Save itsjusteileen/cb49c0b863f71f9fc2c8d963bfbef00c to your computer and use it in GitHub Desktop.
Have members use their email address for logging in to your website powered 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
<?php // Do not include in PMPro Customizations plugin | |
/** | |
* Have members use their email address for logging in to your website powered with Paid Memberships Pro | |
* | |
* Paste the code below into a PMPro Customization Plugin: | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
add_filter( 'gettext', 'wordpress_login_gettext', 20, 3 ); | |
function wordpress_login_gettext( $translated_text, $text, $domain ) { | |
if ( 'wp-login.php' === $GLOBALS['pagenow'] ) { | |
if ( 'Username or Email Address' == $translated_text ) { | |
$translated_text = __( 'Email address' ); | |
} | |
} | |
return $translated_text; | |
} | |
function pmpro_init_email_as_username() { | |
if ( strpos( $_REQUEST['log'], '@' ) !== true ) { | |
$no_continue = pmpro_setMessage( 'Your username should be an email address', 'pmpro_error' ); | |
return false; | |
} | |
} | |
add_action( 'wp', 'pmpro_init_email_as_username' ); | |
function pmpro_gettext_username_to_email( $translated_text, $text, $domain ) { | |
if ( ( 'woocommerce' === $domain || 'pmpro' === $domain || 'paid-memberships-pro' === $domain ) && $text == 'Username or Email Address' ) { | |
$translated_text = 'Email address'; | |
} | |
return $translated_text; | |
} | |
add_filter( 'gettext', 'my_gettext_username_to_email', 15, 3 ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment