Skip to content
  • Log In
  • Register
WordPress.org
  • News
  • Showcase
  • Hosting
    • Themes
    • Plugins
    • Patterns
    • Blocks
    • Openverse ↗︎
    • Learn WordPress
    • Documentation
    • Forums
    • Developers
    • WordPress.tv ↗︎
    • Make WordPress
    • Photo Directory
    • Five for the Future
    • WordCamp ↗︎
    • Meetups ↗︎
    • Job Board ↗︎
    • About WordPress
    • Enterprise
    • Gutenberg ↗︎
    • Swag Store ↗︎
  • Get WordPress
Get WordPress

Developer Resources

Browse: Home / Reference / Hooks / login_message

apply_filters( 'login_message', string $message )

Filters the message to display above the login form.

Contents

  • Parameters
  • More Information
  • Source
  • Related
    • Used By
  • Changelog
  • User Contributed Notes

Parameters

$message string
Login message text.

Top ↑

More Information

The “login_message” filter is used to filter the message displayed on the WordPress login page above the login form. This filter can return HTML markup.


Top ↑

Source

File: wp-login.php. View all references

$message = apply_filters( 'login_message', $message );

View on Trac View on GitHub


Top ↑

Related

Top ↑

Used By

Used By
Used By Description
login_header() wp-login.php

Outputs the login page header.


Top ↑

Changelog

Changelog
Version Description
2.1.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    You must log in to vote on the helpfulness of this noteVote results for this note: 1You must log in to vote on the helpfulness of this note
    Contributed by Razon Komar Pal — 3 years ago

    Add additional message for wp-login.php

    add_filter( 'login_message', 'wpdocs_sr_custom_login_message' );
    function wpdocs_sr_custom_login_message( $message ) {
        $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
        $errors = new WP_Error();
    
        if ( isset( $_GET['key'] ) ) {
            $action = 'resetpass';
        }
    
        if ( isset( $_GET['checkemail'] ) ) {
            $action = 'checkemail';
        }
    
        switch ( $action ):
            case 'register':
                $message .= '<p class="message">' . __( 'Show message before register form.', 'text_domain' ) . '</p>';
                break;
            case 'checkemail':
                $message .= '<p class="message">' . __( 'Show message before after registration complete message.', 'text_domain' ) . '</p>';
                break;
            case 'lostpassword':
                $message .= '<p class="message">' . __( 'Show message before lost password form.', 'text_domain' ) . '</p>';
                break;
            default:
                // this message will show in login screen, before the login form.
                $message .= '<p class="message">' . __( 'Show message before login form.', 'text_domain' ) . '</p>';
                break;
        endswitch;
    
        return $message;
    }
    Log in to add feedback
  2. Skip to note 2 content
    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
    Contributed by Collins Mbaka — 3 years ago

    An example

    function wpdocs_the_login_message( $message ) {
        if ( empty( $message ) ) {
            return '<p>Welcome to this site. Please log in to continue.</p>';
        } else {
            return $message;
        }
    }
    add_filter( 'login_message', 'wpdocs_the_login_message' );
    Log in to add feedback
  3. Skip to note 3 content
    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
    Contributed by Collins Mbaka — 3 years ago

    A plugin can register as a content filter with the code:

    add_filter( 'login_message', 'wpdocs_plugin_function_name' );
    Log in to add feedback
  4. Skip to note 4 content
    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
    Contributed by Akira Tachibana — 3 years ago

    (From Codex)
    Example:

    function the_login_message( $message ) {
        if ( empty($message) ){
            return "<p>Welcome to this site. Please log in to continue</p>";
        } else {
            return $message;
        }
    }
    add_filter( 'login_message', 'the_login_message' );
    Log in to add feedback
  5. Skip to note 5 content
    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
    Contributed by EHLOVader — 6 months ago

    Expanding upon Razon Komar Pal‘s code snippet.

    I found that there are a few other instances that you might wish to show a specific message or not show any additional messages if the provided one is great.

    add_filter( 'login_message', function ( $message ) {
        $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
    
        if ( isset( $_GET['key'] ) ) {
            $action = 'resetpass';
        }
    
        if ( isset( $_GET['checkemail'] ) ) {
            $action = 'checkemail';
        }
    
        if ( isset( $_GET['interim-login'] ) ) {
            $action = 'interim-login';
        }
    
        switch ( $action ) {
            case 'register':
                // $message .= __( 'Show message before register form.', 'text_domain' );
                break;
            case 'checkemail':
                // $message .= __( 'Show message before after registration complete message.', 'text_domain' );
                break;
            case 'lostpassword':
                // $message .= __( 'Show message before lost password form.', 'text_domain' );
                break;
            case 'rp':
                // $message .= __( 'Show message before reset password form.', 'text_domain' );
                break;
            case 'resetpass':
                // $message .= __( 'Show message after reset password form.', 'text_domain' );
                break;
            case 'interim-login':
                // $message .= __( 'Show message before interim login form.', 'text_domain' );
                break;
            default:
                // $message .= __( 'Show message before login form.', 'text_domain' );
                break;
        }
    
        return $message;
    } );
    Log in to add feedback
  6. Skip to note 6 content
    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
    Contributed by Beda — 6 months ago

    Be careful! There is another filter, with a similar description, but applied in a different place!
    https://developer.wordpress.org/reference/hooks/login_messages/

    THAT filter, is for example useful when you want to change the message on the “check mail” screen after a registration.

    Log in to add feedback

You must log in before being able to contribute a note or feedback.

  • About
  • News
  • Hosting
  • Privacy
  • Showcase
  • Themes
  • Plugins
  • Patterns
  • Learn
  • Documentation
  • Developers
  • WordPress.tv ↗
  • Get Involved
  • Donate ↗
  • Swag Store ↗
  • WordCamp ↗
  • WordPress.com ↗
  • Matt ↗
  • bbPress ↗
  • BuddyPress ↗
WordPress.org
WordPress.org
  • Visit our Facebook page
  • Visit our X (formerly Twitter) account
  • Visit our Instagram account
  • Visit our LinkedIn account
  • Visit our YouTube channel
Code is Poetry

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.