login_form_top is a WordPress PHP filter that allows you to display content at the top of the login form, right after the opening form tag element.
Usage
add_filter('login_form_top', 'your_custom_function', 10, 2);
function your_custom_function($content, $args) {
// Your custom code here
return $content;
}
Parameters
- $content (string) – Content to display. Default is empty.
- $args (array) – Array of login form arguments.
More information
See WordPress Developer Resources: login_form_top
Examples
Add a Welcome Message
Display a welcome message at the top of the login form.
add_filter('login_form_top', 'add_welcome_message', 10, 2);
function add_welcome_message($content, $args) {
$content .= 'Welcome to our website! Please log in:';
return $content;
}
Display a Security Notice
Add a security notice informing users about secure login.
add_filter('login_form_top', 'add_security_notice', 10, 2);
function add_security_notice($content, $args) {
$content .= '**Please note:** This login is secured with SSL encryption.';
return $content;
}
Show Login Errors
Display login errors at the top of the form, if any.
add_filter('login_form_top', 'show_login_errors', 10, 2);
function show_login_errors($content, $args) {
$error = $args['error'];
if ($error) {
$content .= "Error: $error";
}
return $content;
}
Add a Logo
Display a logo image at the top of the login form.
add_filter('login_form_top', 'add_logo_to_login', 10, 2);
function add_logo_to_login($content, $args) {
$content .= '<img src="your_logo_url_here" alt="Website Logo" />';
return $content;
}
Display a Maintenance Message
Show a maintenance message at the top of the login form.
add_filter('login_form_top', 'add_maintenance_message', 10, 2);
function add_maintenance_message($content, $args) {
$content .= 'Our website is undergoing maintenance. Some features may be temporarily unavailable.';
return $content;
}