Created
April 11, 2024 14:06
-
-
Save dwanjuki/3ba3d29dcb57f9f8c7b0696ea556a5e8 to your computer and use it in GitHub Desktop.
Change / Translate login page text strings with the gettext filter
This file contains hidden or 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 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_pmpro_run_gettext_on_login_page() { | |
| if ( function_exists( 'pmpro_is_login_page' ) && pmpro_is_login_page() ) { | |
| add_filter( 'gettext', 'my_login_change_text_with_gettext', 10, 3 ); | |
| } | |
| } | |
| add_action( 'wp', 'my_pmpro_run_gettext_on_login_page' ); | |
| 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; | |
| } | |
| return $translated; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment