Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Last active April 30, 2024 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ipokkel/20150d74e9b3716e7b4981a7d38141f7 to your computer and use it in GitHub Desktop.
Save ipokkel/20150d74e9b3716e7b4981a7d38141f7 to your computer and use it in GitHub Desktop.
Change the "Username or Email Address" text string on the PMPro login page (incl. password reset)
<?php
/**
* This recipe will change the "Username or Email Address" text string
* on the login page.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// Let's only do this when on the login page.
function my_pmpro_login_page_only_gettext() {
// Let's only do this on the login page.
if ( function_exists( 'pmpro_is_login_page' ) && pmpro_is_login_page() && function_exists( 'my_pmpro_login_change_text_strings' ) ) {
add_filter( 'gettext', 'my_pmpro_login_change_text_strings', 10, 3 );
}
}
add_action( 'wp', 'my_pmpro_login_page_only_gettext' );
// Change the "Username or Email Address" text string on the login page.
function my_pmpro_login_change_text_strings( $translated_text, $original_text, $domain ) {
// Let's only do this for the "paid-memberships-pro" text domain.
if ( 'paid-memberships-pro' !== $domain ) {
return $translated_text;
}
// Let's change the text strings.
switch ( $original_text ) {
case 'Username or Email Address':
$translated_text = __( 'Email Address', 'paid-memberships-pro' );
break;
case 'Please enter your username or email address. You will receive a link to create a new password via email.':
$translated_text = __( 'Please enter your email address. You will receive a link to create a new password via email', 'paid-memberships-pro' );
break;
}
return $translated_text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment