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.

Where do I put my custom hook code for gform_post_submission

  1. infocus
    Member

    Say my custom hook is something like:

    add_action('gform_post_submission', 'do_something');
    function do_something($entry){
    //Do something code
    }

    Where exactly do I place the above code in form_display.php (or elsewhere) for it to trigger after successful form submission? A line number would be most helpful.

    -------

    Another question... all the sample code has:

    add_action("gform_post_submission", "set_post_content", 10, 2);

    What is the 10 and 2?

    Thanks!

    Posted 12 years ago on Monday August 15, 2011 | Permalink
  2. infocus, that code goes in your theme's functions.php

    http://www.gravityhelp.com/documentation/page/Where_Do_I_Put_This_Code%3F

    Also, the 10 and the 2 are priority (10) and number of arguments (2) the function accepts. Those are WordPress conventions and you can read about them here:

    http://codex.wordpress.org/Function_Reference/add_action#Usage

    Don't make any modifications to the Gravity Forms plugin files. Hooks and filters make modification of the core files unnecessary.

    Posted 12 years ago on Monday August 15, 2011 | Permalink
  3. infocus
    Member

    Ok great thanks!

    I think I got confused as on the bottom of:

    https://s3.amazonaws.com/gravityforms/documentation/gform_post_submission.pdf

    It says "This action hook is located in form_display.php"

    Posted 12 years ago on Tuesday August 16, 2011 | Permalink
  4. The hook is present in the file form_display.php (in other words, that's where Gravity Forms coded it and the function lives.) In case you wanted to dig in and see how it works. But you should never modify the core plugin files. What you want to do is easily possible from functions.php using the available hooks and filters. If you need help with implementation, please let us know.

    Posted 12 years ago on Tuesday August 16, 2011 | Permalink