Home Forums Backend Issues (wp-admin) Gravity Forms Integration with ACF Database addon


Gravity Forms Integration with ACF Database addon

  • Hi All,

    I’ve been using gravity forms as sort of admin panel inside a custom post type to alter ACF fields associated with that post.

    I’ve been loading the ACF field values dynamically into the forms using gform_after_submission set_post content.
    Code is below.

    The issue I’m now having is after installing ACF Database addon to store the content in a more manageable format the gravity form query is still looking at the old post_meta location to populate the form and also the form is no longer updating the fields on submit.

    Rather new to ACF but from what I gather.. for it to be inside the loop which includes the new storage location I have to use get_value rather than get_post_meta.

    Just seeing if anyone has had this issue before and can steer me in the right direction.

    Thanks in advance.

    add_action( ‘gform_after_submission_9’, ‘set_post_content’, 10, 2 );
    function set_post_content( $entry, $form ) {
    global $post;
    global $wp_query;

    //getting post
    $post_id = get_the_ID();

    // $entry[‘post_id’];
    $post_data[‘NEW_contact_name_first’] = get_post_meta($post_id,’NEW_contact_name_first’, true);

    //changing post content
    $NEW_contact_name_first = $entry[‘174’];

    //updating post
    update_post_meta($post_id, ‘NEW_contact_name_first’, $NEW_contact_name_first );

  • Sorry my mistake, code I linked is only to save the form, the form itself is prepopulating via the default values panel in gform. eg {custom_field:NEW_contact_name_first}

  • I would talk to the developer of the ACF add on. But more than likely you will not be able to use this and GF together unless either the ACF add on dev or the GF devs add a way to do so.

  • Hi there!

    Was about to start a project and thought exactly about ACF + Gravity Forms. Essentially forcing the site’s managers to go through a form to change status of a CPT in order to request info to complete the flow.

    Was wondering if you had any resources you’d like to share that you found that would guide me in the right direction or if you had your code in a repo somewhere so I could have a look?

    Also curious as to why you used the ACF Database add-on, what was wrong with just using ACF to handle the DB requests? Thanks a lot!

  • So I’ve played a bit with the code and I have managed to load form in the CPT admin page, when the form is submitted, I’m able to hook the action and run my custom code, but I have no way of getting the post ID where this submission took place:

    add_action( 'gform_after_submission_1', 'do_something', 10, 2 );
    function do_something( $entry, $form ) {
    	global $post;

    Any idea why $post is empty or a way of getting the $post value? Thanks!

  • Woot, solved it, you can get it from $_POST


Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Gravity Forms Integration with ACF Database addon’ is closed to new replies.