This topic has 1 reply, 1 voice, and was last updated 10 years by PaulMRivera.
-
Author
-
March 24, 2014 at 00:18 #13324PaulMRiveraParticipant
So I found the code below and it somewhat works when added to the child functions to have the user verify his/her email when registering. The problem is that it does not show on the registration page until you actually fill out everything and submit the form, then it appears giving the error. Is there something that needs to be tweaked in this code to show automatically on the register page (without having to submit the form for the error check to run?
Code:
function registration_add_email_confirm(){ ?>
<?php do_action( ‘bp_signup_email_first_errors’ ); ?>
<input type=”text” name=”signup_email_first” id=”signup_email_first” value=”
<?php
echo empty($_POST[‘signup_email_first’])?”:$_POST[‘signup_email_first’]; ?>” />
<label>Confirm Email <?php _e( ‘(required)’, ‘buddypress’ ); ?></label>
<?php do_action( ‘bp_signup_email_second_errors’ ); ?>
<?php }
add_action(‘bp_signup_email_errors’, ‘registration_add_email_confirm’,20);function registration_check_email_confirm(){
global $bp;//buddypress check error in signup_email that is the second field, so we unset that error if any and check both email fields
unset($bp->signup->errors[‘signup_email’]);//check if email address is correct and set an error message for the first field if any
$account_details = bp_core_validate_user_signup( $_POST[‘signup_username’], $_POST[‘signup_email_first’] );
if ( !empty( $account_details[‘errors’]->errors[‘user_email’] ) )
$bp->signup->errors[‘signup_email_first’] = $account_details[‘errors’]->errors[‘user_email’][0];//if first email field is not empty we check the second one
if (!empty( $_POST[‘signup_email_first’] ) ){
//first field not empty and second field empty
if(empty( $_POST[‘signup_email’] ))
$bp->signup->errors[‘signup_email_second’] = ‘Please make sure you enter your email twice’;
//both fields not empty but differents
elseif($_POST[‘signup_email’] != $_POST[‘signup_email_first’] )
$bp->signup->errors[‘signup_email_second’] = ‘The emails you entered do not match.’;
}
}
add_action(‘bp_signup_validate’, ‘registration_check_email_confirm’);March 24, 2014 at 02:16 #13334PaulMRiveraParticipantJust letting you know that the code above works. No other code is necessary. My cache was not cleared and now it works.
-
AuthorPosts
The topic ‘Verify Email on Registrations’ is closed to new replies.