How to Add a Custom Message to the WordPress Login Screen

Home » Snippets » How to Add a Custom Message to the WordPress Login Screen
0

Created with:

Visibility: 

public

Creator: Alex

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

Customizing the login screen on your WordPress site can help you create a unique experience for your users. One way to do this is by adding a custom message to the login screen. This message can be used to provide important information, such as contact details or site rules, and can be easily added with just a few lines of code. In this article, we’ll show you how to add a custom message to the login screen of your WordPress site.

					function wpturbo_custom_login_message() {
    $message = "<p class='wpturbo-custom-message'>" . __( 'Your custom message goes here.', 'wpturbo' ) . "</p>";
    return $message;
}
add_filter( 'login_message', 'wpturbo_custom_login_message' );
				

The code snippet above is designed to add a custom message to the WordPress login screen. This can be useful for communicating important information or branding to users who are attempting to log in to your site.

The code first defines a new function called wpturbo_custom_login_message(). This function is responsible for generating the HTML markup that will be used to display the custom message.

Inside the function, we create a variable $message that contains the HTML used to display the custom message. The message is wrapped in a paragraph tag with a custom class of wpturbo-custom-message.

$message = "<p class='wpturbo-custom-message'>" . __( 'Your custom message goes here.', 'wpturbo' ) . "</p>";

Change Your custom message goes here. to your own custom message.

We use the WordPress __() function to handle translation of the message. This ensures that the message can be translated into different languages if necessary.

The last step is to use the add_filter() function to hook the wpturbo_custom_login_message() function into the login_message filter. This tells WordPress to use our custom function to generate the HTML markup for the login screen message.

add_filter( 'login_message', 'wpturbo_custom_login_message' );

Once this code is added to your WordPress site, your custom message will be displayed on the WordPress login screen.

Register an account to save your snippets or go Pro to get more features.