Skip to content

Instantly share code, notes, and snippets.

@yuriinalivaiko
Last active November 24, 2025 18:03
Show Gist options
  • Select an option

  • Save yuriinalivaiko/772146e00f0c22ca7598fa636afd9c3f to your computer and use it in GitHub Desktop.

Select an option

Save yuriinalivaiko/772146e00f0c22ca7598fa636afd9c3f to your computer and use it in GitHub Desktop.
This code adds custom email template "Verified Users - Account is not verified" to be used in the "Ultimate Member - Verified Users" extension.
<?php
/**
* Add custom email template "Verified Users - Account is not verified".
*
* @param array $emails Emails list.
* @return array
*/
function um_email_notification_unverify_user( $emails ) {
// New email templates.
$custom_emails = array(
'unverify_user' => array(
'key' => 'unverify_user',
'title' => __( 'Verified Users - Account is not verified', 'um-verified' ),
'description' => __( 'Send a notification to user when his account is not verified', 'um-verified' ),
'recipient' => 'user',
'default_active' => true,
'subject' => 'Your account is not verified on {site_name}',
'body' => 'We have reviewed your verification request. '
. 'Unfortunately we can not verify your account now. '
. 'Please update your profile and fill all required fields.<br /><br />'
. 'To view your profile click here: {user_profile_link}<br /><br />'
. 'Thank You!<br />'
. '{site_name}',
),
);
foreach ( $custom_emails as $slug => $custom_email ) {
// Default settings.
if ( '' === UM()->options()->get( $slug . '_on' ) ) {
$email_on = empty( $custom_email['default_active'] ) ? 0 : 1;
UM()->options()->update( $slug . '_on', $email_on );
}
if ( '' === UM()->options()->get( $slug . '_sub' ) ) {
$email_sub = empty( $custom_email['subject'] ) ? $slug : $custom_email['subject'];
UM()->options()->update( $slug . '_sub', $email_sub );
}
// Template file.
$located = UM()->mail()->locate_template( $slug );
if ( ! file_exists( $located ) ) {
wp_mkdir_p( dirname( $located ) );
file_put_contents( $located, $custom_email['body'] );
}
$emails[ $slug ] = $custom_email;
}
return $emails;
}
add_filter( 'um_email_notifications', 'um_email_notification_unverify_user' );
/**
* Send a notification to user when his account is not verified.
*
* @param int $user_id User ID.
*/
function um_email_notification_unverify_user_send( $user_id ) {
$userdata = get_userdata( $user_id );
$email = $userdata->user_email;
um_fetch_user( $user_id );
UM()->mail()->send( $email, 'unverify_user' );
}
add_action( 'um_after_user_is_unverified', 'um_email_notification_unverify_user_send', 20, 1 );
@yuriinalivaiko
Copy link
Copy Markdown
Author

yuriinalivaiko commented Feb 4, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment