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.

gform condition statement?

  1. rovillesarate
    Member

    Hi! What condition should i use to check if what gform is loaded?

    ex: if ( gform = gform1 ) { execute code }

    How do i do this? Im trying to submit a cookie value after post submission but i dont want all my forms to be affected by the function.

    Any Suggestions?

    Posted 13 years ago on Thursday January 6, 2011 | Permalink
  2. rovillesarate
    Member

    Im trying to use this code but would like to insert a condition statement to prevent other forms from using this

    add_action("gform_post_submission", "post_submission_cookie");
    function post_submission_cookie($entry){
    // insert condition here to know if gform is equals to gform[id]
        setcookie("dh_country", $_POST["input_" . $field["1"]], time() + 31536000, COOKIEPATH, COOKIE_DOMAIN, false, true);

    }

    Posted 13 years ago on Thursday January 6, 2011 | Permalink
  3. Try something like this: http://pastie.org/1433020

    A few things to note:

    add_action("gform_post_submission_1", "post_submission_cookie", 10, 2);

    The 1 after gform_post_submission_ is the ID of the form you'd like to run the function on.

    $_POST["input_" . $field["1"]]

    The $entry which is passed to the function by the hook array actually contains all the values submitted by the form so if you're trying to get the value of field ID 1, you can just use $entry[1].

    Hope this helps!

    Posted 13 years ago on Thursday January 6, 2011 | Permalink
  4. rovillesarate
    Member

    Wow! Thanks. Will try the code. =D

    Posted 13 years ago on Thursday January 6, 2011 | Permalink
  5. rovillesarate
    Member

    Hi! Is this code correct?

    setcookie("dh_country", $_POST[$entry[1]], time() + 31536000, COOKIEPATH, COOKIE_DOMAIN, false, true);

    Posted 13 years ago on Thursday January 6, 2011 | Permalink
  6. setcookie("dh_country", $entry[1], time() + 31536000, COOKIEPATH, COOKIE_DOMAIN, false, true);

    Since the $entry array already has the value available, you don't have to mess with the $_POST at all. :)

    Posted 13 years ago on Thursday January 6, 2011 | Permalink