Some time ago I’ve seen from the server log of a client buddypress site that lot of registration email were bouncing back. It was clear that for the most part they were mispelled and the client decided it was better to add another registration field then loosing a good amount of new members (bouncing emails was 4-5% of successful registrations).
As I read on the forum that other people were asking for email confirm field, I decided to inaugurate a new category for Hacks & Tutorials with this little snipped that add another email field and check it.
Paste this code in your bp-custom.php file or in your custome theme function.php. I tested it only with that site, but it should work with every buddypress site that use the default theme or a child of it. If you have problem ask detalied question with all your software versions, your site url and any error message.
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');
WordPress and BuddyPress have a very good hook system so they can be easily customized with short snippets. Is there some other widely useful customization needed?
Pingback: The Link Edition: Friday Find | Premium BuddyPress Themes at BuddyDress
Hi
I want to disable email confirmation when a user registers to my site. so when a user signs up a new account, he would be able to login and post immadiately after his sign up, without any email activation.
I searched for plugins, but i found nothing. can you help me?
Hi Amin,
first of all, are you sure you really wanna to do it? it has some cons:
- you’ll not have a verified way to contact members
- if someone use a valid mail of someone else to register then your site will be sending notification emails to someone that has not opted-in for them and has no way to stop them. This is bad.
After a very quick look to the signup/activation code I think is possible but the solution depends on how wp is installed (single site/multi site) and probably the version too.
So if you still are sure of it I’ll have a deeper look when I have some free time, leave here the version of your wp (that should be 3, otherwise update it) and if you are using it as a single or multi site install.
yes I think you are right, it’s better not to disable it.
anyway, thank you for your reply
—–
em, I cheked the “notify me of follow up comments via e-mail” in this post, but I didn’t receive any email. maybe you should fix it.
thanks for the notice, I’ll look in it
Thanks Francesco = works like a charm..
This is a great tool…. this is one surefire way I had for spammers to stop spamming a user registration….. everything else I tried…failed….but this one
Is there a simple way to modify this to make it so only a certain email domain can be used + throw an error message stating you must use a valid @example.com email address to register?
I hope this helps my site. I also duplicated the function and added a hidden honey pot field..