Run save post after APC form submitted

APC works like a charm when making a woo product on the front end. However, when I print the array of meta saved by this process, there are only a handful there.

If I then load the WP admin page for this new product and simply hit Update without changing anything, loads more are added.

How can I add in an action to do that update post action after the GF form is processed?

You can use the gform_post_submission action hook in WordPress to trigger an update for the post after the Gravity Forms form is processed. The code would look something like this:

add_action( 'gform_post_submission', 'update_product_after_submission', 10, 2 );

function update_product_after_submission( $entry, $form ) {
  $post_id = $entry['post_id'];
  wp_update_post( array( 'ID' => $post_id ) );
}

This hook is a handy tool for developers, as it is called after the form is submitted, and allows you to perform additional actions, such as updating a post. In this case, you use the wp_update_post function to update the post with the ID specified in the $post_id variable.

Thanks Faisal! Much appreciated, and my apologies for not spotting your reply before now.

Sadly, that doesn’t seem to work. Do you know of any other hooks to call the wp_update_post function that might do the job?

See if the following page of the documentation helps:

Additionally, the gform_post_submission hook is deprecated. Instead of that, you should use gform_after_submission if you decide to go that route:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.