Skip to content
escapecreative.io
Tutorials WordPress

Add a WordPress Custom Login Message

Updated

Jun 13, 2018

Written by

Dave Warfel

Reading Time

2 minutes

If you buy something from one of our links, we may earn a commission.

Want to display a custom message on your WordPress login page? We’ll walk you through adding a custom login message to WordPress’ wp-login.php page. We’ll use existing styling provided in WordPress core, and the login_message filter to make it all happen.

Adding a WordPress Custom Login Message to wp-login.php

You could add this code directly to your theme’s functions.php file, but I prefer to use the Code Snippets plugin. The Code Snippets plugin allows you to create custom functionality on your WordPress site using actions & filters, without the need to sort through a bunch of code in your functions.php file. It’s a much safer and more manageable way to insert custom code.

Here’s the code that will add a custom login message to your login page in WordPress:

/* Add message above login form */
function wpsd_add_login_message() {
	return '<p class="message">Use this form to login to the administration area of WordPress, and make changes to your website.</p>';
}
add_filter('login_message', 'wpsd_add_login_message');

We’re creating a function called wpsd_add_login_message, and adding it to the wp-login.php page using the filter, login_message. We use a class of .message so the text uses WordPress’ core styling for message blocks. You can choose to omit that if you’d like, or add your own styling.

You can include any HTML markup you’d like. You’re not limited to a <p> tag.

Whatever you choose to add to your custom login message, it will be rendered directly above the <form id="loginform" ... > tag.

WordPress custom login message
Example of the WordPress custom login message in action. Displayed directly above the <form> tag on wp-login.php.

We Recommend

Kinsta – Blazingly Fast WordPress Hosting 🚀
https://kinsta.com › wordpress-hosting
Fast and secure infrastructure, worldwide CDN, edge caching, 35 data centers, and enterprise-level features included in all plans. Free site migrations.
Best WordPress Form Plugin for 2024 – Gravity Forms
https://gravityforms.com › features
Create custom web forms to capture leads, collect payments, automate your workflows, and build your business online. All without ever leaving WordPress.

Dave Warfel

LinkedIn  •  X (Twitter)Dave has been working with WordPress since 2011. He's built 100s of client sites and almost a dozen of his own. He's tested almost every plugin you can think of, hosted with at least 10 different companies, and gone down every SEO rabbit hole you can imagine. When's he's not tinkering with new software, you'll find him in the mountains of Colorado, trail running, summiting peaks, and rippin' downhills on his mountain bike. 🏔️🏃🚴🤸
Enhance and extend your forms with Gravity Forms

Table of Contents

16 responses to “Add a WordPress Custom Login Message”

  1. Michael Avatar
    Michael
    Aug 26, 2015

    Thank you for this! I’ve looked all over for a way to let people know they are agreeing to receive emails from the site if they register and login. Kind of a round-about way of Opt-in emails. Anyway, thanks – it works perfectly.

    Reply
    1. Dave Warfel Avatar
      Dave Warfel
      Aug 26, 2015

      @Michael – Excellent! I’m glad you found it useful. Best of luck with your email marketing efforts.

  2. Benito Avatar
    Benito
    Apr 1, 2016

    Thanks for this, it works great!

    Reply
    1. Dave Warfel Avatar
      Dave Warfel
      Apr 1, 2016

      You’re welcome, Benito. I’m glad you found it useful, even after 2+ years.

  3. Todd Avatar
    Todd
    Feb 3, 2017

    Thanks, I’d like to insert the site-title instead of a text message (I use the same functions.php file on different sites) – can you advise how to insert that in the function?

    Reply
    1. Dave Warfel Avatar
      Dave Warfel
      Feb 7, 2017

      Hi Todd,

      I haven’t tested this, but you can try something like this:

      return '<p class="message">Use this form to login to' . get_the_title() . ', and make changes to your website.</p>';

      or you can try the_title() instead of get_the_title().

      Let me know if either of those work for you.

  4. Nicola Avatar
    Nicola
    Apr 13, 2017

    Thanks. Is it possible to add a custom message to the registration page as well and possibly remove the default “register for this site” message?

    Reply
    1. Dave Warfel Avatar
      Dave Warfel
      Apr 18, 2017

      Nicola,

      You can remove the “Register for this site” message using CSS, but it will require some code to be put either in a custom plugin or your theme’s functions.php file.

      add_action('login_head', 'login_page_styles');
      
      function login_page_styles() {
        echo '<style>
          .message.register {
          	display: none;
          }
        </style>';
      }

      This article will show you how to add a custom message to the registration page, below the form fields.

    2. Nicola Avatar
      Nicola
      Apr 18, 2017

      Thanks Dave, I finally did it by selectively change the message using the parameters in the url

      <?php
      function change_reg_message($message) {
      	if (isset($_GET['action'])&&$_GET['action']==='register') {
      		return 'Custom message';
      	}
      	return $message;
      }
      add_action('login_message', 'change_reg_message');
      ?>
      
    3. Dave Warfel Avatar
      Dave Warfel
      Apr 18, 2017

      Nicely done! Thanks for sharing your method.

  5. Stuart Avatar
    Stuart
    Dec 22, 2017

    Brilliant. Thank you Dave. Spent ages hunting for a plugin that would do this and this is much simpler (and lighter on the site). I’d add a note to say it is better to do via ftp than wordpress appearance editor as I didn’t have success with the latter.
    Thank you

    Reply
    1. Dave Warfel Avatar
      Dave Warfel
      Dec 29, 2017

      Glad you found it helpful, Stuart!

  6. Sam Gallo Avatar
    Sam Gallo
    Jun 13, 2018

    I’m not a code writer but need this ability to write message on the login page. Where in the code lines of the login file do you place the additional code? Anyplace? Where?

    Reply
  7. Sam Gallo Avatar
    Sam Gallo
    Jun 13, 2018

    I got it working. I placed it just after } // End of login_header()

    Thanks. Great!

    Reply
    1. Dave Warfel Avatar
      Dave Warfel
      Jun 13, 2018

      Hi Sam,

      I’m glad you got it working, but I wanted to chime in real quick.

      I’m not sure where you placed the code, but it’s best practice to never edit WordPress core files directly. WordPress core files include those in the root directory, and all those inside the /wp-admin/ and /wp-includes/ folders. When new versions of WordPress are released, those files can be replaced, and your code could be removed.

      I mentioned placing this code in your theme’s functions.php file. But honestly, there is a plugin that would be much easier, especially for a non-coder like yourself.

      I would recommend you install the Code Snippets plugin. Then create a new snippet and add the code to it. That’s the safest way to apply the code.

  8. Desarrollo Web Sur Avatar
    Desarrollo Web Sur
    Nov 20, 2019

    Muchas gracias, me sirvió.

    Reply

Leave a Comment Cancel reply

Site Update

We're completely rebuilding the site from scratch using only the block editor. There's also a new brand in the works, as well as a slightly different focus.

We'll still cover WordPress (heavily), but we'll be branching out to cover other online software as well. Ecommerce, form builders, automation tools, SEO software, writing/editing software, CRMs, and other no-code platforms.

About

Legal

Escape Creative, LLC © 2013-2025