I want to hide the login message that shows up on the Wordpress login form after a user has logged out. Added screenshot of the message that I am trying to hide.


Wordpress Version 5.4.2

Wordpres theme: Oceanwp 1.8.9

I have used the below mentioned code in the functions.php file of my theme.

add_filter( 'wp_login_errors', 'my_logout_message' );

function my_logout_message( $errors ){

    if ( isset( $errors->errors['loggedout'] ) ){
        return null;

    return $errors;

Error Recieved:

I have provided the screen shot of the error that I have recieved.


Also, the login form isn't visible after user logout.

  • What's the reason behind this? Can you provide some context?
    – Tom J Nowell
    Sep 24, 2020 at 21:32

1 Answer 1


The cause of your error is that the filter receives and is expected to return a WP_Error object, null is not an error object.

We can confirm this via the docs, and enforce it via type hinting:

function my_logout_message( \WP_Error $error ) : \WP_Error {

Additionally, if your code had worked, all errors would be eliminated, not just the logout message. There would be no way to tell a user their password was incorrect, that a password reset email or a confirmation email was on its way, etc

With this in mind, the WP_Error say there is a remove method, so we can remove the loggedout error if it's present:

$error->remove( 'loggedout' );

I do not recommend this though

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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