Yeah, I can't follow all that. But there's a vbulletin function is_valid_email() that you can call. It just does this:
Code:
return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>@,;]+\.+[a-z]{2,6}))$#si', $email);
But if what you're saying is that you have one input field named email, but it might be a user name, then I think you'd want to do this:
Code:
$vbulletin->input->clean_gpc('p', 'email', TYPE_STR);
$input_email = htmlspecialchars_uni($vbulletin->GPC['email']);
if (is_valid_email($input_email))
{
if (empty($email))
{
$email = $input_email;
}
}
else
{
if (empty($username))
{
$username = $input_email;
}
}
This probably bypasses the check for a valid/unused username, but that just means the user would just get an error after submitting.