| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 4 |
|
| 5 |
add_shortcode( 'wppb-resend-activation', 'wppb_toolbox_resend_activation_url_handler' ); |
| 6 |
function wppb_toolbox_resend_activation_url_handler() { |
| 7 |
$button_name = __('Resend activation email', 'profile-builder'); |
| 8 |
$output = '<form enctype="multipart/form-data" method="post" id="wppbc-resend_activation" class="wppb-user-forms" action="">'; |
| 9 |
$output .= ' |
| 10 |
<li class="wppb-form-field'. apply_filters( 'wppb_resend_activation_extra_css_class', '', 'resend_activation_email') .'"> |
| 11 |
<label for="username_email" style="padding-right: 30px;">'.__( 'Email', 'profile-builder' ).'</label> |
| 12 |
<input class="text-input" name="email" type="text" id="username_email" value="" '. esc_attr( apply_filters( 'wppb_resend_activation_extra_attr', '', __( 'Email', 'profile-builder' ), 'text' ) ) .'/> |
| 13 |
<div style="padding-top: 20px;"> |
| 14 |
<input name="resend_activation" type="submit" id="wppbc-resend-activation-button" class="submit button" value="'. esc_attr( $button_name ) . '" /> |
| 15 |
<input name="action" type="hidden" id="action" value="wppbc_resend_activation" /> |
| 16 |
<input type="hidden" name="wppb_nonce" value="'. esc_attr( wp_create_nonce( 'wppbc_resend_activation' ) ) . '" /> |
| 17 |
</div> |
| 18 |
</li> |
| 19 |
</form>'; |
| 20 |
|
| 21 |
return apply_filters('wppb_resend_activation_form_before_content_output', $output); |
| 22 |
} |
| 23 |
|
| 24 |
add_action( 'init', 'wppb_toolbox_resend_activation_url', 999 ); |
| 25 |
function wppb_toolbox_resend_activation_url() { |
| 26 |
if( isset($_REQUEST['action']) && $_REQUEST['action'] === 'wppbc_resend_activation' && isset($_REQUEST['email'] ) && isset( $_REQUEST['wppb_nonce'] ) && wp_verify_nonce( sanitize_text_field( $_REQUEST['wppb_nonce'] ), 'wppbc_resend_activation' )) { |
| 27 |
global $wpdb; |
| 28 |
$sql_result = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->base_prefix . "signups WHERE user_email = %s", sanitize_email( $_REQUEST['email'] ) ), ARRAY_A ); |
| 29 |
|
| 30 |
if ( $sql_result ){ |
| 31 |
wppb_signup_user_notification( trim( $sql_result['user_login'] ), trim( $sql_result['user_email'] ), $sql_result['activation_key'], $sql_result['meta'] ); |
| 32 |
echo '<script> alert("'. esc_html__( 'Activation email sent!', 'profile-builder' ) .'");</script>'; |
| 33 |
} |
| 34 |
else { |
| 35 |
echo '<script> alert("'. esc_html__( 'No sign-up was made with that email!', 'profile-builder' ) .'");</script>'; |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
|