WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Jul 20 2010

How to Add a Custom Message on the Login or Register Screen

custom  login message
Click for a Larger Image

For one of my projects, I was asked to make the entire WordPress Blog login protected whereby people had to request via a form on the site for access. In doing this everyone was redirected to the login form without a registration link (because they did not want to use the traditional WordPress registration and preferred a manual registration). Anyways, I had to add a message on the login screen to point people to a contact form. Since WordPress 2.8, you can add a custom_login_message. There are a ton of plugins that will help you customize the look of the login screen; however, none that I could find helped you add any text or links to the login screen without simply highjacking the core code or replacing all of the wp-login.php file with a custom one. So here is what you can do:

[php]function custom_login_message() {
$message = "<p class='message'>Welcome, if you haven't already, you need to be <a href='http://photoblog.smithsaga.com/registration/'>registered</a> to see content.</p><br />";
return $message;
}
add_filter('login_message', 'custom_login_message');
?>[/php]

The p class='message' puts the message in a yellow box. If you prefer red, simply change message to login_error.

And if you want a custom message on the registration screen:

[php]function custom_register_message() {
$message = "<p class='message'>Welcome, if you haven't already, you need to be <a href='http://photoblog.smithsaga.com/registration/'>registered</a> to see content.</p><br />";
return $message;
}
add_filter('register_message', 'custom_register_message');
[/php]

Written by Travis Smith · Categorized: Tutorials

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. TrevorR says

    October 9, 2010 at 4:45 am

    Interesting… Are you saying I can modify this to change what WordPress outputs for the div id=”login_error”? Right now my only solution is to use a display:none for the “a” tag within this div to remove what it outputs.

    If so can you explain exactly how I can change the “login_error” text? I’d post this on WP.org if you can as well because a few people have tried to do this without success. Thank you!!

    Trevor

    Reply
  2. elie palima says

    February 8, 2011 at 2:37 pm

    hello travis. thanks for this tutorial. it’s working great! however, can you teach me how to remove the login message on the ‘log out’ page??? thanks.

    Reply
    • Travis Smith says

      February 8, 2011 at 6:53 pm

      Hello Elie,

      Check out: https://wpsmith.net/wordpress/how-to-add-a-custom-login-logout-message-in-wordpress/

      Thanks,

      Reply
  3. Justin says

    April 26, 2011 at 12:53 pm

    Great function!

    I was wondering, is there an easy way to add a custom message for the registration page as well?

    I know your Smithers Login will do it, but my site is a little Plugin Heavy and I already have Register Plus Redux installed, and wouldn’t want any conflicts.

    All help really, massively appreciated!

    Thanks

    Reply
    • wpsmith says

      April 27, 2011 at 9:27 am

      Hello Justin,

      I believe there is. With WordPress 3.0-3.1, you should be able to use the hooks before_signup_form and after_signup_form. So something like this should work, but I haven’t tested it. Please let me know if it works!

      [php]<?php
      //Add Style
      function my_register_stylesheet() {
      ?>
      <style type="text/css">
      .mu_alert { font-weight:700; padding:10px; color:#333333; background:#ffffe0; border:1px solid #e6db55; }
      </style>
      <?php
      }
      add_action( ‘wp_head’, ‘my_register_stylesheet’ );

      //Add Message
      add_action(‘before_signup_form’,’my_registration_custom_msg’);
      function my_registration_custom_msg() { ?>
      <div class="mu_alert">
      TEST
      </div>
      <?php }
      ?>[/php]

      Reply
  4. florbv says

    June 1, 2013 at 11:20 pm

    Hello, Travis! How can I modify the message in the screen upon new user’s clicking the Register button? As of now it says, “Registration completed. Log in now.” I want to change it into: “Please check your email to activate your account.” Thank you.

    Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in