GENWiki

Premier IT Outsourcing and Support Services within the UK

User Tools

Site Tools


rsformpro:filtering_screening_out_free_email_accounts_in_forms

If you're a b2b or just someone who doesn't want spammy forms being submitted all the time from free email accounts then this filter is for you, but it can easily be adjusted to filter any domains you want. This code needs to be added into the Form Properties / PHP Scripts / Script Called on form display section. We assume here that the field is called 'email'. Change yours to be 'email' or change the first line and last but one line of this code to use your chosen field name.

$email=$_POST['form']['email'];
 
$domain = substr($email, strpos($email, '@')+1 );
$domain = strtolower(substr($domain, 0, strpos($domain,".")));
preg_match('/(hotmail|outlook|gmail|google|yahoo|hustmail|msn|protonmail|aol|gmx|yandex|zoho|icloud|mail|lycos|tutanota)/', $domain, $check);
if (!empty($check)) {
    // email is free crap spammer
    $invalid[] = RSFormProHelper::getComponentId("email");
}

We can easily see above that the regex (preg_match) is just a list of domain names that are to be rejected. You can of course add/change this as required. If the returned $check from the preg_match is empty then we're good to go, otherwise we use RsFormPro!'s built in $invalid array to return that back and have the input rejected.

/data/webs/external/dokuwiki/data/pages/rsformpro/filtering_screening_out_free_email_accounts_in_forms.txt · Last modified: 2020/04/18 09:58 by genadmin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki