|
<?php |
|
/* Template Name: Confirmation Link Page */ |
|
get_header();?> |
|
<div class="inner-page-container"> |
|
<div class="container"> |
|
<div class="row"> |
|
<div class="col-sm-12 thankyou-signup"> |
|
<h1 class="blue-title">Almost Finished!</h1> |
|
<div class="page-desp"> |
|
<?php |
|
if( isset($_POST['new_user_submit']) ) : |
|
$new_user_first_name = stripcslashes( $_POST['fname']); |
|
$new_user_last_name = stripcslashes( $_POST['lname']); |
|
$new_user_email = stripcslashes($_POST['email']); |
|
$confirmaion_hash_key = md5( rand(0,1000) ); |
|
$new_user_password = md5(rand(1000,5000)); |
|
$user_data = array( |
|
'user_login' => $new_user_email, |
|
'user_email' => $new_user_email, |
|
'first_name' => $new_user_first_name, |
|
'last_name' => $new_user_last_name, |
|
'role' => 'subscriber' |
|
); |
|
$new_user_id = wp_insert_user($user_data); |
|
if (!is_wp_error($new_user_id)) { |
|
$activation_link = get_permalink(get_page_by_path('email-verification')).'?email='.$new_user_email.'&hash='.$confirmaion_hash_key; |
|
$email_content = "A mail has been sent to your email address. Please follow the link to activate your account"; |
|
update_user_meta($new_user_id,'activated','false'); |
|
$to = $new_user_email; // Send email to our user |
|
$subject = 'Signup Verification'; // Give the email a subject |
|
$message = 'Your login credential'; |
|
$message .= 'Username: '.$new_user_email.'<br /> |
|
Password: '.$new_user_password.'<br /> |
|
Please click on the following link or copy the link and paste it to your browser to activate your profile and Sign in.' |
|
.$activation_link.'; |
|
|
|
// Our message above including the link |
|
$headers = "From: " Your Name .<Your Email>\r\n"; |
|
$headers .= "Reply-To: "Your Email"\r\n"; |
|
$headers .= "MIME-Version: 1.0\r\n"; |
|
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; |
|
$headers .= "Content-Transfer-Encoding: 7BIT"; |
|
wp_mail($to, $subject, $message, $headers); // Send our email |
|
} else { |
|
if (isset($new_user_id->errors['empty_user_login'])) { |
|
$notice_key = 'User Name and Email are mandatory'; |
|
echo $notice_key; |
|
} elseif (isset($new_user_id->errors['existing_user_login'])) { |
|
echo'<p>User name already exixts.</p>'; |
|
} else { |
|
echo'<p>Error Occured please fill up the sign up form carefully.</p>'; |
|
} |
|
} |
|
else: |
|
echo 'You have not submitted the form'; |
|
endif; |
|
|
|
</div> |
|
|
|
</div><!--container ends--> |
|
</div><!--inner-page-container ends--> |
|
|
|
<?php get_footer();?> |