- This topic is empty.
-
AuthorPosts
-
June 17, 2011 at 6:00 pm #33163
jlau
MemberHi there,
I’ve created a custom registration page using Registration Plus Redux and I need to create a more specific email validation. Basically I need to only allow ‘ac.uk’ email addresses to register. But I need people to be able to register with emails such as:
and also
Any help would be greatly appreciated. I have tried to use a plugin called ’email validation’ or something similar, but it hasn’t been updated in over a year and either doesn’t work or isn’t compatible with registration plus redux.
Thanks in advance
June 18, 2011 at 10:20 am #72584ddliu
MemberHi jlau, I guess you are meaning “how to validate such an email address”.
Basically you may have a regular expression to do this in PHP, and maybe following code will work for you:
if(preg_match('#^[a-z0-9_.-]{1,50}@([a-z0-9_-].){0,5}ac.uk$#i',$email)){
echo "Yeah, you have an ac.uk email address!";
}
else{
echo "Oops, your email address is not valid or is not an ac.uk email address!";
}
June 19, 2011 at 10:43 pm #81878jlau
MemberHi ddliu,
Thanks a lot for the reply. I really appreciate it. I’m not super comfortable with php/wordpress. So where would I put this code in my theme to get it to affect my registration?
If it helps my website is http://www.heruni.com
June 20, 2011 at 2:18 am #81889ddliu
MemberI don’t think it’s in the theme, you may change it here:
file wp-login.php, find function “register_new_user”, find code:
// Check the e-mail address
if ( $user_email == '' ) {
$errors->add( 'empty_email', __( 'ERROR: Please type your e-mail address.' ) );
} elseif ( ! is_email( $user_email ) ) {
$errors->add( 'invalid_email', __( 'ERROR: The email address isn’t correct.' ) );
$user_email = '';
} elseif ( email_exists( $user_email ) ) {
$errors->add( 'email_exists', __( 'ERROR: This email is already registered, please choose another one.' ) );
}
add following code at the end of the if…else… scope:
elseif (!preg_match('#[@.]ac.uk$#i', $user_email){
$errors->add( 'invalid_email', __( 'ERROR: Only "ac.uk" email address allowed.' ) );
$user_email = '';
}
Maybe there is a way to change it in the theme? I have no idea, don’t know that much.
June 23, 2011 at 10:07 am #82192jlau
MemberThanks a lot! It worked well :)
If anyone else wants to use this code. Theres a right bracket missing after $user_email.
Does anyone know how to change this from the theme?
December 12, 2016 at 2:40 am #248899Anonymous
InactiveHi , its very easy to verify Email validation. For Email Validation you can simply go through this site http://www.melissadata.in/cloud-services/global-email-cloud-service
December 12, 2016 at 2:49 am #248901Shikkediel
ParticipantOne link might be useful if it’s relevant enough. But three in a row without anything else and I’d say you’re a spammer.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.