Follow-Up Email a Few Days After Sign-Up
Sends new users a second, friendly email a few days after they register, with tips or links to get started, scheduled automatically with WP-Cron.
Opens WPIDE on
Code
$wpide_followup = array(
'days' => 3,
'subject' => 'Getting the most out of {site}',
'message' => "Hi {name},\n\nThanks for joining {site} a few days ago! Here are a few things to try next:\n\n• Complete your profile\n• Browse our latest articles\n• Reply to this email if you have any questions\n\nSee you soon!",
);
add_action( 'user_register', function ( $user_id ) use ( $wpide_followup ) {
wp_schedule_single_event( time() + $wpide_followup['days'] * DAY_IN_SECONDS, 'wpide_followup_email', array( (int) $user_id ) );
} );
add_action( 'wpide_followup_email', function ( $user_id = 0 ) use ( $wpide_followup ) {
$user = get_userdata( (int) $user_id );
if ( ! $user || ! is_email( $user->user_email ) ) {
return;
}
$site = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
$replace = array( '{name}' => $user->first_name ? $user->first_name : $user->display_name, '{site}' => $site );
wp_mail( $user->user_email, strtr( $wpide_followup['subject'], $replace ), strtr( $wpide_followup['message'], $replace ) );
} );
Notes
Edit the delay, subject and message at the top ({name} and {site} are replaced); the email is skipped if the account has been deleted meanwhile.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.