Using WordPress ‘login_form_{$action}’ PHP action

The login_form_{$action} WordPress PHP action fires before a specified login form action. The dynamic portion of the hook name, $action, refers to the action that brought the visitor to the login form.

Usage

add_action('login_form_{$action}', 'your_custom_function');
function your_custom_function() {
// your custom code here
}

Parameters

None

More information

See WordPress Developer Resources: login_form_{$action}

Examples

Adding a message before the login form

Display a custom message before the login form.

add_action('login_form_login', 'your_custom_message_function');
function your_custom_message_function() {
echo '<p><strong>Welcome!</strong> Please enter your credentials to log in.</p>';
}

Displaying a message before the lost password form

Add a message to guide users before the lost password form.

add_action('login_form_lostpassword', 'your_lost_password_message_function');
function your_lost_password_message_function() {
echo '<p>Forgot your password? No worries, enter your email and we\'ll help you reset it.</p>';
}

Adding content before the registration form

Display custom content before the registration form.

add_action('login_form_register', 'your_custom_registration_content_function');

function your_custom_registration_content_function() {
    echo '<p>Join our amazing community by creating a new account below.</p>';
}

Displaying a message before the password reset form

Add a message to guide users before the password reset form.

add_action('login_form_resetpass', 'your_password_reset_message_function');

function your_password_reset_message_function() {
    echo '<p>Enter your new password below to reset your account password.</p>';
}

Adding a message before the logout action

Display a custom message before the logout action takes place.

add_action('login_form_logout', 'your_custom_logout_message_function');

function your_custom_logout_message_function() {
    echo '<p>Thank you for visiting! You are now being logged out.</p>';
}