This topic has 1 reply, 1 voice, and was last updated 10 years by PaulMRivera.

  • Author
  • #13324
     PaulMRivera
    Participant

    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’);

    #13334
     PaulMRivera
    Participant

    Just letting you know that the code above works. No other code is necessary. My cache was not cleared and now it works.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Verify Email on Registrations’ is closed to new replies.

Log in with your credentials

Forgot your details?