uo_forgot_before_container
Fires before the forgot password form container is rendered, allowing customization.
add_action( 'uo_forgot_before_container', $callback, 10, 1 );
Description
Fires before the main container for the forgotten password form. Developers can use this hook to add custom content or modify the form's structure before it's rendered. It's crucial for integrating custom elements or altering the default layout of the forgotten password page.
Usage
add_action( 'uo_forgot_before_container', 'your_function_name', 10, 1 );
Examples
<?php
/**
* Example function to demonstrate the 'uo_forgot_before_container' action hook.
* This function will add a custom message before the forgot password form container.
*/
function my_custom_forgot_password_message() {
// Check if the current user is logged out. This hook is typically for logged-out users.
if ( ! is_user_logged_in() ) {
echo '<div class="my-custom-forgot-message" style="margin-bottom: 20px; padding: 10px; border: 1px solid #ddd; background-color: #f9f9f9;">';
echo '<h3>Lost your password?</h3>';
echo '<p>Please enter your username or email address below, and we will send you an email with instructions on how to reset your password.</p>';
echo '</div>';
}
}
add_action( 'uo_forgot_before_container', 'my_custom_forgot_password_message', 10 );
/**
* Another example: Enqueue a custom stylesheet specifically for the forgot password page
* using the 'uo_forgot_before_container' hook.
*/
function enqueue_custom_forgot_styles() {
// Only enqueue if the modern UI is active, to avoid conflicts.
if ( uncanny_learndash_toolkitFrontendLoginPlus::is_modern_ui() ) {
wp_enqueue_style(
'my-custom-forgot-styles',
get_stylesheet_directory_uri() . '/css/my-custom-forgot.css',
array(),
filemtime( get_stylesheet_directory() . '/css/my-custom-forgot.css' )
);
}
}
add_action( 'uo_forgot_before_container', 'enqueue_custom_forgot_styles', 5 ); // Lower priority to ensure it runs before the form is rendered.
/**
* Example: Conditionally show a specific message based on a plugin setting.
* Let's assume there's a custom plugin option to display a support contact.
*/
function show_support_contact_on_forgot() {
// Retrieve a hypothetical option from WordPress options table.
$support_email = get_option( 'my_plugin_support_email' );
if ( ! empty( $support_email ) ) {
echo '<p style="font-size: 0.9em; color: #555;">If you continue to experience issues, please contact our support team at: <a href="mailto:' . esc_attr( $support_email ) . '">' . esc_html( $support_email ) . '</a></p>';
}
}
add_action( 'uo_forgot_before_container', 'show_support_contact_on_forgot', 20 ); // Higher priority to appear after the main message.
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/modern_ui-lost-pwd.php:15
src/templates/frontend-login/layout_1-lost-pwd.php:15
}
$login_page = uncanny_learndash_toolkitFrontendLoginPlus::get_login_redirect_page_id();
$login_page_url = get_permalink( $login_page );
?>
<?php do_action( 'uo_forgot_before_container' ); ?>
<?php
// Enqueue color overrides for Modern UI
if ( FrontendLoginPlus::is_modern_ui() ) {
FrontendLoginPlus::enqueue_modern_ui_colors();
}
?>