uo_login_after_validation_message
Fires after user login validation, allowing custom actions and messages to be displayed to the user.
add_action( 'uo_login_after_validation_message', $callback, 10, 1 );
Description
Fires after the login validation error message is displayed. Developers can use this hook to append custom content or modify the validation message area after the primary error is shown.
Usage
add_action( 'uo_login_after_validation_message', 'your_function_name', 10, 1 );
Examples
add_action( 'uo_login_after_validation_message', 'my_custom_login_error_handler', 10, 0 );
/**
* Custom function to handle login validation messages.
* This example adds a specific class to the error notice if a certain condition is met.
*/
function my_custom_login_error_handler() {
// In a real-world scenario, you might want to access global variables or
// session data to determine what to do here.
// For this example, let's pretend we want to add an extra visual cue
// for a specific type of login error, like an invalid username.
// This is a hypothetical check. In reality, the '$error' variable from the
// original context might be accessible or you might need to pass it
// via the hook or a global. Since the hook doesn't pass arguments,
// we'll simulate a condition.
// Let's assume we have a way to know if the error is due to an invalid username.
// In a real plugin, this logic would be tied to how the error message is generated.
$is_invalid_username_error = false; // Replace with actual logic if available
// You would typically check the actual error message or an error code.
// For demonstration, let's hardcode a condition or assume a global variable.
if ( isset( $_SESSION['last_login_error_type'] ) && 'invalid_username' === $_SESSION['last_login_error_type'] ) {
$is_invalid_username_error = true;
}
if ( $is_invalid_username_error ) {
// You could output a hidden input field, add a data attribute, or
// directly modify the HTML if the hook allowed for output modification.
// Since this hook is placed within a span, direct output might not be ideal
// without affecting the layout. A more common approach would be to set
// a global variable or use another hook to modify the output.
// For demonstration, let's imagine we're adding a data attribute to a parent element.
// This is a bit tricky with just do_action here. A better approach might be
// to have this hook *set* a variable that the template then *reads* to add attributes.
// Let's simulate setting a global variable that the template can use.
// In a real plugin, this would be done more robustly.
if ( ! isset( $GLOBALS['my_custom_login_error_class'] ) ) {
$GLOBALS['my_custom_login_error_class'] = '';
}
$GLOBALS['my_custom_login_error_class'] .= ' custom-invalid-username-error';
}
}
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:128
src/templates/frontend-login/modern_ui-login.php:128
<div class="ult-form__validation <?php echo implode( ' ', $css_classes ); ?>">
<div class="ult-notice ult-notice--error">
<?php do_action( 'uo_login_before_validation_message' ); ?>
<span class="ult-notice-text"><?php echo $error; ?></span>
<?php do_action( 'uo_login_after_validation_message' ); ?>
</div>
</div>
<?php
// End output
$output = ob_get_clean();