Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress: How do I customize "Lost your password" text on login page?

I realize this is probably simple, but I can't figure out how to change the "Lost your password" text on the WordPress login page.

On the login page, there is a link that says, "Lost your password," and I want to change that text to read something like, "Get a new password." I'm just not sure what function to use to overwrite that text in the child theme.

Screenshot of wordpress login screen

like image 416
jasonTakesManhattan Avatar asked Dec 07 '16 16:12

jasonTakesManhattan


People also ask

How do I change my WordPress password reset page?

To do that, head over to the Formidable » Global Settings and then click the 'Registration' tab in the menu. From here you need to find the 'Reset Password Page' option and then simply select the page you just created from the drop down menu.

How do I recover my WordPress login details?

From the login page, click Lost your password? and enter either your WordPress.com username or email address. You'll receive an email with a link that will let you designate a new password and regain access to your site.


3 Answers

Change wordpress text "Lost your password?"

function change_lost_your_password ($text) {

             if ($text == 'Lost your password?'){
                 $text = 'Forgot Password?';

             }
                    return $text;
             }
    add_filter( 'gettext', 'change_lost_your_password' );
like image 131
dev Avatar answered Nov 09 '22 11:11

dev


To change this text or any text for that matter you can use the following function, it's almost the same Super Model's answer but documented and code standards validated.

/**
 * Change some text.
 *
 * @param String $text WordPress Text Stream.
 * @return String
 */
function acme_change_some_text( $text ) {
    if ( 'Lost your password?' === $text ) {
        $text = 'Forgot Your Password?';
    }

    // Important to return the text stream.
    return $text;
}

// Hook this function up.
add_action( 'gettext','acme_change_some_text' );

Here's a handy gif to explain what's happening.

GIF

like image 21
Ahmad Awais Avatar answered Nov 09 '22 13:11

Ahmad Awais


The function has several parameters to change the default settings. For instance, you can specify: the ID names of the form and its elements (for CSS styling), whether to print the "Remember Me" checkbox, and the URL a user is redirected to after a successful login (default is to stay on the same Page):

<?php
if ( ! is_user_logged_in() ) { // Display WordPress login form:
    $args = array(
        'redirect' => admin_url(), 
        'form_id' => 'loginform-custom',
        'label_username' => __( 'Username custom text' ),
        'label_password' => __( 'Password custom text' ),
        'label_remember' => __( 'Remember Me custom text' ),
        'label_log_in' => __( 'Log In custom text' ), //you can change here
        'remember' => true
    );
    wp_login_form( $args );
} else { // If logged in:
    wp_loginout( home_url() ); // Display "Log Out" link.
    echo " | ";
    wp_register('', ''); // Display "Site Admin" link.
}
?>

The form itself is generated by code in the WordPress wp-includes/general-template.php file. Because your custom login Page is different than the built-in WordPress login page (wp-login.php)

like image 40
Ivan Barayev Avatar answered Nov 09 '22 13:11

Ivan Barayev