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.

Try to edit a post...most hooks are not called

  1. cohen
    Member

    Hello,
    I am trying to edit post data with gravity forms.
    I want to have for example one custom type post "contact", that holds the complete information
    of a contact. I created an extra "Contact Page"-Template, that contains the Gravity form for the contact. To show the form on this page I created the function "showBEForm($form_type)". $form_type is the ID of the contact form. This function is called from my page-template. Pre populating the data with the "gform_pre_render"-filter works correctly. But all other actions or filters (gform_pre_submission, gform_disable_post_creation, gform_pre_submission) are never called.
    So I always get an extra contact-post by pressing submit and I am not able to edit the existing one.
    You can find the sourcecode at http://www.pastie.org/3380707.
    I really hope you can help me.

    Posted 13 years ago on Tuesday February 14, 2012 | Permalink
  2. Hi, cohen,

    Are you also enqueueing the necessary scripts for Gravity Forms? When embedding a form using the function call "gravity_form", you also have to manually enqueue the javascript/css files. So until you do that you will have jquery errors that may be impacting the rest of your code. Take a look at this article on how to embed the form and enqueueing the scripts: http://www.gravityhelp.com/documentation/page/Embedding_A_Form . The enqueueing needs to go in your header.

    Also, have you tried putting your Gravity Forms filters into your theme's functions.php file? I copied out your code and once I put them into that file, they were actually used.

    Try that out and let me know if you have questions.

    Posted 13 years ago on Thursday February 16, 2012 | Permalink
  3. cohen
    Member

    Hi Dana,
    thanks for your answer. It helped me a lot.
    I put all the addFilter and addAction stuff in the functions.php of my theme. Now it works.
    All the hooks are called.
    Pre populating forms with posts and editing them now works really charming with custom post fields.
    I just have a problem with multiple input fields like the advanced "address" field.
    I am not able to pre populate such multiple fields.
    I use the following code in my pre populate hook:

    function populate_data($form)
    {
    foreach ($form['fields'] as &$field) {
    if($field['inputName']!=null){
    $field['defaultValue']=get_post_meta($Post_ID,$post_data_name,true);
    }
    if($field['inputs']){
    foreach($field['inputs'] as $input){
    //is it possible to set a default value in here to set value for e.g. advanced address fields

    }
    }
    }

    return $form;
    }

    Perhaps you can give me a hint how to pre populate such fields.

    Posted 13 years ago on Wednesday February 22, 2012 | Permalink
  4. Take a look at this forum topic which may help you with pre-populating complex fields (like address and name) - http://www.gravityhelp.com/forums/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form .

    Posted 13 years ago on Tuesday February 28, 2012 | Permalink

This topic has been resolved and has been closed to new replies.