PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Add_filter not working after update to 1.6.2

  1. Anonymous
    Unregistered

    Hello, We had an "add_filter" set up for validation that used to work before upgrading to the latest version. We can not figure out why it isnt working now. Could you please help us figure out why? I have copied and pasted the code below.

    [php]
    //code
    
    add_filter('gform_validation', 'custom_validation');
    
    function custom_validation($validation_result){
    
    #value = $_POST['input_9'];
    
    $em=$value;
    
    $ar=split("@",$em);
    
    $domain = explode("@", $value);
    
    $domain = $domain[(count($domain)-1)];
    
    $blacklist = array('yahoo-inc.com');
    
    if (in_array($domain, $blacklist)) {
    
    echo $ar[1];
    
    // set the form validation to false
    
    $validation_result["is_valid"] = false;
    
    //finding Field with ID of 1 and marking it as failed validation
    
    foreach($validation_result["form"]["fields"] as &$field){
    
    //NOTE: replace 1 with the field you would like to validate
    
    if($field["id"] == "9"){
    
    $field["failed_validation"] = true;
    
    $field["validation_message"] = "Only commercial (non-free) Email accounts are accepted.";
    
    break;
    
    }
    }
    }
    return $validation_result;
    }
    
    // END CODE
    Posted 12 years ago on Tuesday December 27, 2011 | Permalink
  2. There are no known issues with using the gform_validation hook and Gravity Forms v1.6.2. It's extensively used by things such as our own Add-Ons, etc. So if implemented properly it should work.

    What I would suggest is review your code, make sure everything matches up with what you are trying to do (field id's, etc.) and do a code review and then do some more tests to see if it's something unrelated.

    If after doing so you are unable to figure out what could be wrong, let us know and we can dig deeper and assist you. Just keep in mind that this is a customization so non-customization related support requests take priority over customization related code issues. But we'd be glad to take a look if after doing the above you are unable to determine why it is not working.

    Posted 12 years ago on Wednesday December 28, 2011 | Permalink
  3. Anonymous
    Unregistered

    Hi Carl,

    We didn't change anything with the validation code, the only change was updating to the latest GF (that's when it broke). This is an important customer so we would appreciate getting some help resolving this issue. The PHP validation code has always worked in the past, we need to figure out what changed between this version of GF and the last in order to identify the issue and resolve it.

    Thanks.

    Posted 12 years ago on Wednesday December 28, 2011 | Permalink
  4. Is this accurate or a typo?

    [php]
    #value = $_POST['input_9'];

    Should it be?

    [php]
    $value = $_POST['input_9'];
    Posted 12 years ago on Wednesday December 28, 2011 | Permalink