WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Feb 08 2011

How to Add a Custom Login/Logout Message in WordPress

In a previous post, How to Add a Custom Message on the Login or Register Screen, I talked about how to add a custom message to either the login screen or the register screen. Recently, I was asked how to create a custom message for logging out. Since WordPress uses the wp-login.php file to logout as well, then it isn't as simple as the last post.

So, to add a custom message to your logout screen, you need to add the following to your functions.php file.

[php]function custom_login_head() //outputs the CSS needed to blend custom-message with the normal message
{?>
<style type="text/css">
#login_error, .message { display:none; }
.custom-message {
-moz-border-radius:3px 3px 3px 3px;
border-style:solid;
border-width:1px;
margin:0 0 16px 8px;
padding:12px;
}
.login .custom-message {
background-color:#FFFFE0;
border-color:#E6DB55;
}
</STYLE><?php
}

add_action('login_head','custom_login_head');

function custom_logout_message() {
if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] ) //check to see if it's the logout screen
{
$message = "<p class='custom-message'>Custom logged out Message.</p><br />";
}
else //they are logged in
{
$message = "<p class='custom-message'>Custom Login Message.</p><br />";
}

return $message;
}
add_filter('login_message', 'custom_logout_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. Marlita Hill says

    March 18, 2013 at 12:16 am

    Hi Travis. Your tutorials have been so helpful. I have two questions:
    1. I entered your code to customize the register message but it shows the same message I have on the login page.

    2. On the logout screen, it shows the login message PLUS the “you are now logged out message.” How do I get rid of the login message on the logout page?

    Thank you.
    Marlita

    Reply
  2. per says

    April 4, 2013 at 5:04 pm

    Hi
    I seeking for a custom message when a user has been logout by the plugin we are using “Automatic sign out for inactivity”. I assume I can use your script but I need to adjust it somewhere but I can’t figure out where and how! Any idea how I can adjust this to happen?

    Per

    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