• Resolved bvk69varghese

    (@bvk69varghese)


    Hi,

    I have integrated the login and Registration form. When I submit the login form with incorrect password I am getting this message. ” Error: The password you entered for the email address [email protected] is incorrect. パスワードをお忘れですか?.” I need to translate this message. Forgot password part is already translated and that part is coming as translated. How to change the entire text with my custom text? How to do this. Please let me know. I have tried the below code and I am not able to translate.

    add_filter('wpv_filter_override_auth_errors', 'my_translation_func', 10, 3);
    function my_translation_func($error_string, $wp_error, $fail_reason){
       echo "fail reason ".$fail_reason;exit;
        if($fail_reason == 'incorrect_password'){
            $error_string = 'エラー: パスワードが正しくありません。もう一度試してください。';
        }
        return $error_string;
    }
    
    add_filter( 'gettext', function( $translation, $text, $domain )
    {
        if ( 'default' !== $domain )
            return $translation;
    
        if ( '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s" title="Password Lost and Found">Lost your password</a>?' !== $text )
            return $translation;
    
        return 'Custom password message';
    }, 10, 3 );
    
    add_filter( 'wp_login_errors', 'override_incorrect_password_msg', 10, 2 );
    function override_incorrect_password_msg( $errors, $redirect_to ) {
        if( isset( $errors->errors['incorrect_password'] ) ) {
            $errors->errors['incorrect_password'][0] = 'Your new message';
        }
    
        return $errors;
    }
    
    add_filter( 'gettext', function( $translation, $text, $domain )
    {
        if ( 'default' !== $domain )
            return $translation;
    
        if ( '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s" title="Password Lost and Found">Lost your password</a>?' !== $text )
            return $translation;
    
        return 'Custom password message';
    }, 10, 3 );

    Please help me to resolve this.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @bvk69varghese !

    I trust you’re doing great!

    Please try the following snippet instead of the one you’ve shared:

    add_filter( 'gettext', function( $translation, $text, $domain ) {
        if ( '<strong>Error</strong>: The password you entered for the username %s is incorrect.' !== $text )
            return $translation;
    
        return 'Custom password message';
    }, 10, 3 );

    The ‘Custom password message’ can be changed to anything you need.

    Warm regards,
    Pawel

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @bvk69varghese ,

    We haven’t heard from you for a while now, so it looks like you don’t need our assistance anymore.

    Feel free to re-open this ticket if needed.

    Kind regards
    Kasia

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Translation issue’ is closed to new replies.