uo_user_verified
Fires after a user is manually verified. Fires after a user is manually verified, providing the verified user's ID and the ID of the admin who performed the verification.
add_action( 'uo_user_verified', $callback, 10, 2 );
Description
Fires after a user is manually verified. This action hook provides the ID of the verified user and the ID of the admin who performed the verification. Developers can use this hook to trigger custom actions, such as sending notifications, updating user roles, or logging verification events.
Usage
add_action( 'uo_user_verified', 'your_function_name', 10, 2 );
Parameters
-
$user_id(int) - The verified user's ID.
-
$verifier_id(int) - The user (admin) that verified the user.
Examples
/**
* Example: Send a welcome email to a newly verified user.
*
* This function is hooked into the 'uo_user_verified' action and sends a
* personalized welcome email to the user who has just been verified.
*/
add_action( 'uo_user_verified', 'my_send_welcome_email_on_verification', 10, 2 );
function my_send_welcome_email_on_verification( $user_id, $verifier_id ) {
// Get the user object for the verified user.
$user = get_user_by( 'id', $user_id );
if ( ! $user ) {
return; // Exit if the user object cannot be retrieved.
}
// Construct the email subject.
$subject = sprintf( __( 'Welcome to %s, %s!', 'your-text-domain' ), get_bloginfo( 'name' ), $user->display_name );
// Construct the email message.
// You can personalize this further by retrieving user-specific data or settings.
$message = sprintf(
__( "Hello %s,nnCongratulations! Your account has been successfully verified by %s. We're excited to have you on board.nnBest regards,nThe %s Team", 'your-text-domain' ),
$user->display_name,
get_user_by( 'id', $verifier_id )->display_name, // Get the display name of the verifier
get_bloginfo( 'name' )
);
// Set the email headers.
$headers = array( 'Content-Type: text/plain; charset=UTF-8' );
// Send the email.
// wp_mail() is the WordPress function for sending emails.
wp_mail( $user->user_email, $subject, $message, $headers );
// Optionally, you could update user meta here to track that the welcome email was sent.
// For example: update_user_meta( $user_id, 'welcome_email_sent', 'yes' );
}
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/classes/frontend-login-plus.php:1461
* Fires after a user is manually verified.
*
* @param int $user_id The verified user's ID.
* @param int $verifier_id The user (admin) that verified the user.
*
* @since 3.4.1
*/
do_action( 'uo_user_verified', $user_id, $verifier_id = get_current_user_id() );
}
$verified = get_user_meta( $user_id, 'uo_is_verified', true );
$verified_email_sent = get_user_meta( $user_id, 'uo_verified_email_sent', true );
if ( $verified === '1' && 'yes' !== $verified_email_sent ) {