uo_forgot_before_success_message
Fires before the success message is displayed after a successful password reset request.
add_action( 'uo_forgot_before_success_message', $callback, 10, 1 );
Description
Fires just before the success message is displayed on the "Forgot Password" page. This hook allows developers to inject custom content or modify the success message dynamically before it's outputted to the user.
Usage
add_action( 'uo_forgot_before_success_message', 'your_function_name', 10, 1 );
Examples
<?php
/**
* Example of using the 'uo_forgot_before_success_message' action hook.
* This function will prepend a custom message to the default success message
* when a password recovery request is successfully processed.
*/
add_action( 'uo_forgot_before_success_message', 'my_custom_forgot_success_message', 10, 1 );
/**
* Adds a custom message before the default success message for password recovery.
*
* @param object $forgot_password_response The response object from the password recovery process.
* This might contain properties like 'message'.
*/
function my_custom_forgot_success_message( $forgot_password_response ) {
// Check if the response object is valid and has a message property.
// This is a precautionary check, as the original hook is likely called
// after a successful operation.
if ( is_object( $forgot_password_response ) && property_exists( $forgot_password_response, 'message' ) ) {
// You can dynamically generate this message based on various factors if needed.
// For this example, we'll use a static message.
echo '<p><strong>Great news!</strong> Your password recovery request has been processed.</p>';
}
}
// Note: The 'uo_forgot_before_success_message' hook in the provided context
// does not explicitly pass any parameters to the hooked function in the
// original PHP code snippets. However, the context implies that the
// $forgot_password_response object is available in the scope where the hook is called.
// Therefore, we've defined our function to accept one parameter, assuming
// it will be the $forgot_password_response object.
//
// If the hook *actually* passed no arguments, the function definition would be:
// function my_custom_forgot_success_message() { ... }
// and the add_action would be:
// add_action( 'uo_forgot_before_success_message', 'my_custom_forgot_success_message', 10, 0 );
//
// Given the presence of 'echo $forgot_password_response->message;' right after the hook,
// it's highly probable that the $forgot_password_response object is what the hook is intended to provide.
// The 'accepted_args' parameter in add_action is set to 1 to receive this object.
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:49
src/templates/frontend-login/layout_1-lost-pwd.php:42
src/classes/frontend-login-plus.php:3554
<?php echo $innerText['Password-Recovery-Title']; ?>
</div>
<?php do_action( 'uo_forgot_before_success' ); ?>
<div class="ult-form__row ult-form__row--validation">
<div class="ult-notice ult-notice--success">
<?php do_action( 'uo_forgot_before_success_message' ); ?>
<?php echo $forgot_password_response->message; ?>
<?php do_action( 'uo_forgot_after_success_message' ); ?>
</div>
</div>
<?php do_action( 'uo_forgot_after_success' ); ?>