Hi, currently utilizing a form to have a "login" field where user inputs email address and if the domain is correct they get redirected to a page. We need to have a redirect in place for when a user inputs an email not recognized by our whitelist and they get sent to another page - this redirect needs to be able to account for all different email domains.
Here is current code snippet setup that support provided:
add_filter('frm_redirect_url', 'return_page', 9, 3);
function return_page($url, $form, $params){
if($form->id == 664){ //change 5 to the ID of the form to redirect
$field_id = 15678; //change 25 the the ID of your field
$postedvalue = $_POST['item_meta'][$field_id]; //We are storing the value submitted in the field in the variable $postedvalue. And we will create our logic using that variable.
if(strpos($postedvalue, '@yahoo') !== false || strpos($postedvalue, '@google') !== false || strpos($postedvalue, '@facebook') !== false ) //If the value submitted contains @yahoo (You can modify that your preferred string)
{
$url = 'https://faang.com';
}
else if(strpos($postedvalue, '@amazon') !== false || strpos($postedvalue, '@ebay') !== false || strpos($postedvalue, '@next') !== false)
{
$url = 'https://google.com';
}
}
return $url;
}
With the code above, if the email contains @yahoo or @google or @facebook, you will be redirected to faang.com. If the email contains @amazon or @ebay or @next, you will be redirected to google.com.
Ideally, need to adjust to function like the "if like" "if not like" conditionals - i.e.
[if 45 like="@business.com"]https://address.com/accepted[/if 45]
[if 45 not_like="@business.com"]https://address.com/rejected[/if 45]
so there is a catch all solution for domains not accounted for. Currently the redirect doesn't happen but instead a blank white page opens with no messaging.
Appreciate any insight anyone can provide.
You can include an else in Formidable conditionals:
[if 45 like="@business.com"]https://address.com/accepted[else]https://address.com/rejected[/if 45]
Can this be used with multiple email addresses/domains? I tried [if 45 like="@domain.com; name@gmail.com"] and [if 45 like="@domain.com, name@gmail.com"] and it redirects to error page.
We usually have a few domains and at least 1 individual email address we need to whitelist - otherwise the "else" would be perfect. 🙁
Please login or Register to submit your answer