Resend Confirmation Email

This function adds a shortcode which allows your users to request another email confirmation message.

Shortcode:

[wppb-resend-activation]

You can add this shortcode to your website using the Customization Toolbox add-on.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
  * Resend activation email from front-end, publicly available. Tags: resend email confirmation, activation link
  */
 add_shortcode('wppb-resend-activation', 'wppc_resend_activation_funct');
 function wppc_resend_activation_funct(){
 	$button_name = __('Resend activation email', 'profile-builder');
 	$output = '<form enctype="multipart/form-data" method="post" id="wppbc-resend_activation" class="wppb-user-forms" action="">';
 	$output .= '
		<li>
			<label for="username_email" style="padding-right: 30px;">'.__( 'E-mail', 'profile-builder' ).'</label>
			<input  class="text-input" name="email" type="text" id="username_email" value="" />
			<div style="padding-top: 20px;">
				<input name="resend_activation" type="submit" id="wppbc-resend-activation-button" class="submit button" value="'. $button_name . '" />
				<input name="action" type="hidden" id="action" value="wppbc_resend_activation" />
			</div>
		</li>
 	</form>';
 
 	return $output;
 }
 
 add_action('init','wppbc_resend_activation_to_user', 999);
 function wppbc_resend_activation_to_user(){
 	if(isset($_REQUEST['action']) && $_REQUEST['action']=='wppbc_resend_activation' && isset($_REQUEST['email'])) {
 		global $wpdb;
 		$sql_result = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->base_prefix . "signups WHERE user_email = %s", $_REQUEST['email'] ), ARRAY_A );
 
 		if ( $sql_result ){
 			wppb_signup_user_notification( trim( $sql_result['user_login'] ), trim( $sql_result['user_email'] ), $sql_result['activation_key'], $sql_result['meta'] );
 			echo '<script> alert("Activation email sent!");</script>';
 		}
 		else {
 			echo '<script> alert("No sign-up was made with that email!");</script>';
 		}
 	}
 }