1

I have tried searching for this, and I have found it is possible to change the login error messages using a hook. But I cannot find how to change this error message:

ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.

Which appears if cookies are disabled and you try to login. How do I customize this text?

Thank you!

  • 1
    This message is coded in wp-login.php but is not filterable. Though it is of course translatable via gettext, so maybe you could take advantage of this as a possible way to customize it. – Iceable Jun 13 '18 at 10:40
  • 1
    @Iceable gettext is filterable, so you can use that filter and modify this text. – Krzysiek Dróżdż Jun 13 '18 at 11:41
1

This text is hardcoded in wp-login.php file (line 886):

$user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ),
                __( 'https://codex.wordpress.org/Cookies' ) ) );

and as you can see, there is no filter used to generate it... Almost no filter. Why almost? Because it is translated and that means that you can use gettext filter to modify it.

function my_change_cookies_disabled_error( $translated_text, $text, $domain ) {
    $default = '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.';

    if ( $translated_text == $default ) {
        $translated_text = __( '<strong>ERROR</strong>: My error message', 'my_text_domain' );
    }

    return $translated_text;
}
add_filter( 'gettext', 'my_change_cookies_disabled_error', 20, 3 );
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.