How to Add Custom Message on WordPress Login Page

In today’s tutorial, we’ll learn how to customize our WordPress login page by adding custom message on WordPress login page. This is an example of our default login page:

default login page

The default login page looks very plain. Let’s add some useful text to our login page. To add or edit a custom message to our login page, we can use login_message filter. The filter can return an HTML output. Here’s an example of the complete snippet that can be copied:

1 2 3 4 5 6 7 8 9 10 11 12 13
<?php
//* Add custom message to WordPress login page
function afn_custom_login_message( $message ) {
if ( empty($message) ){
return "<p>Welcome to our site. Please log in to continue</p>";
} else {
return $message;
}
}
add_filter( 'login_message', 'afn_custom_login_message' );
view raw functions.php hosted with ❤ by GitHub

Here’s the result of what you’ll see on your login page:

custom message on WordPress login page

I suggest you to put the code inside your site functionality plugin, not on your theme’s functions.php file since this is not a theme-specific feature. By placing the code in your functionality plugin, the custom message won’t be removed when you change your theme in future. In future, we hope to cover more tutorial on customizing your login page. Previously, we’ve also published a tutorial on adding a popup registration form to your WordPress site. For more WordPress tutorials, feel free to subscribe to our RSS feed. You won’t be disappointed.

Comments

  1. Dave says

    Would you mind sharing the purpose for this part:

    `if ( empty($message) ){`

    Does that mean it will only show this message if none of the default WordPress messages (logged out, password reset sent, etc.) are being displayed?

    Also, to stay consistent with styling, you can add a class to the p tag: “. That produces a design like this screenshot.

  2. Bennie says

    Howdy this is kinda of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding experience so I wanted to get guidance from someone with experience. Any help would be greatly appreciated!

    • Editor says

      If you’re asking about WordPress, then the answer is yes. Feel free to contact us if you’d like ask anything about WordPress.

Leave a Reply

Your email address will not be published. Required fields are marked *