Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JarrydLong/7b455bb74251a645b63ea411a45e640c to your computer and use it in GitHub Desktop.
Save JarrydLong/7b455bb74251a645b63ea411a45e640c to your computer and use it in GitHub Desktop.
Change / Translate login page text strings with the gettext filter
<?php // do not copy this line
/**
* This recipe changes login page text strings with the gettext filter
*
* 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/
*/
function my_login_change_text_with_gettext( $translated, $text, $domain ) {
switch ( $text ) {
case 'Username or Email Address':
$translated = 'Your translation here.';
break;
case 'Password':
$translated = 'Your translation here.';
break;
case 'Remember Me':
$translated = 'Your translation here.';
break;
case 'Log In':
$translated = 'Your translation here.';
break;
case 'Join Now':
$translated = 'Your translation here.';
break;
case 'Get New Password':
$translated = 'Your translation here.';
break;
case 'Lost Password?':
$translated = 'Your translation here.';
break;
case 'Please enter your username or email address. You will receive a link to create a new password via email.':
$translated = 'Your translation here.';
break;
case 'The %s fields are required.':
$output_text = 'Translated Text with %s field names'; // %s is a placeholder for the field name
break;
case 'The %s field is required.':
$output_text = 'Translated Text with %s field names'; // %s is a placeholder for the field name
break;
case 'Please complete all required fields.':
$output_text = 'Translated Text';
break;
case 'Email':
$output_text = 'Translated Text';
break;
}
return $translated;
}
add_filter( 'gettext', 'my_login_change_text_with_gettext', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment