Appnitro Software Forums » MachForm

Blocking emailadresses from email field [urgent]!

(6 posts)

  1. MvdL79
    Member

    Yuniar,

    A "quick" question; is there a fast way to block email accounts like @hotmail.com, @msn.com, @gmail.com, @live.nl, etc. from the email field?

    Our company does not accept orders from those emailaccounts.

    Please advice... Thanks in advance!

    Posted 1 month ago #
  2. MvdL79
    Member

    Oh and if it's possible only for specific forms, so we can still use, for example, Hotmail accounts on some forms (e.g. migration forms).

    Currently we have about 14 active forms. However from form 1 through 11 it's not allowed to use free emailaccounts like Hotmail and Gmail, but on forms 12 through 14 it is allowed to use these.

    Hopefully I made myself clear! Thank you.

    Posted 1 month ago #
  3. Hi,

    In this case you should add another validation to block those e-mails. Open your "includes/common-validator.php" and add those code on line 28.

    //validation for email address
    function validate_blacklist_mail($value){
    
    	//define blocked email address
    	$block_email_list = '@test.com,@wow.com';
    
    	$blacklisted_mail = explode(',',strtolower($block_email_list));
    
    	if(in_array(strstr($value[0],'@'),$blacklisted_mail)){
    		return 'This email not allowed';
    	} else {
    		return true;
    	}			
    
    }

    in there I assume you want to block e-mail from test.com and wow.com. After that edit your "includes/post-functions.php" and search on line 289, you'll find this code :

    $rules[$element_name]['email'] = true;

    add exactly below that code to activate the validation:

    $rules[$element_name]['email'] = true;
    if ($form_id == '11') {
    	$rules[$element_name]['blacklist_mail'] = true;
    }

    Finnaly it also filter the validation only for form 11 :).

    Posted 1 month ago #
  4. MvdL79
    Member

    Okay thanks!! You are a life-saver. :)
    I will give it a go!

    Posted 1 month ago #
  5. yes they will get 'This email not allowed', to add custom message simply change those message.

    return 'This email not allowed';
    Posted 1 month ago #
  6. MvdL79
    Member

    Works great! Thanks! :)

    //edit

    Yeah I overlooked the message part, my bad! :)

    Posted 1 month ago #

RSS feed for this topic

Reply

You must log in to post.