uo_login_before_form
Fires before the login form is displayed, allowing for custom actions and modifications.
add_action( 'uo_login_before_form', $callback, 10, 1 );
Description
Fires before the frontend login form is rendered. This hook allows developers to inject custom content, modify form elements, or perform actions immediately preceding the login form's display, such as adding security checks or additional fields.
Usage
add_action( 'uo_login_before_form', 'your_function_name', 10, 1 );
Examples
<?php
/**
* Example function to hook into 'uo_login_before_form'.
* This function demonstrates how to add custom content or logic
* right before the login form itself is rendered.
*
* In this example, we'll add a simple message if the user is already logged in,
* or display a reminder about password reset options if they are not.
*
* The hook 'uo_login_before_form' does not pass any arguments.
*/
function my_custom_login_before_form_message() {
// Check if the user is currently logged in.
if ( is_user_logged_in() ) {
// If logged in, display a friendly message.
echo '<p class="ult-form__notice">You are already logged in!</p>';
} else {
// If not logged in, remind them about password reset.
// We assume a function like 'wp_lost_password_url()' exists or a custom one.
// For realism, let's assume a standard WordPress function.
$lost_password_url = wp_lost_password_url();
if ( $lost_password_url ) {
echo '<p class="ult-form__reminder">Forgot your password? <a href="' . esc_url( $lost_password_url ) . '">Reset it here</a>.</p>';
}
}
}
// Add the custom function to the 'uo_login_before_form' action hook.
// The third parameter '1' indicates that our function accepts 0 arguments.
add_action( 'uo_login_before_form', 'my_custom_login_before_form_message', 10 );
?>
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/templates/frontend-login/layout_1-login.php:187
src/templates/frontend-login/modern_ui-login.php:194
<div class="ult-form__description">
<?php echo $login->strings->description; ?>
</div>
<?php } ?>
<?php do_action( 'uo_login_before_form' ); ?>
<div class="ult-form__container">
<?php
if ( uo_toolkit_2fa_form_exists() ) {
uo_toolkit_2fa_render_authentication_form();
} else {