Hey all,
I’m attempting to use Gravity Forms and Advanced Post Creation to accomplish a relatively simple task, but I can’t seem to get it to work. Wondering if anyone can point me in the right direction?
Basically, I have a ACF number field in an options page called books_global
. Then I have a form with a number field called books_single
. When a user fills out the form, a new post is created and the content of the post should be a calculation of the books_global
field and the books_single
field. (I know, it’s an odd setup, but the client wants this updated number to be in an RSS feed, so I figured it would be easy enough to accomplish with posts.)
So global_books
should always be a iterating whatever folks enter into the number field in the form.
I have the post creation part set up, but I not able to hook into the form submission to grab books_global
and do my calculation. This is what I have now:
add_action( 'gform_advancedpostcreation_post_after_creation_1', function ( $post_id, $feed, $entry, $form ){
$books_single = $entry['1']; // the number field from the form
$books_global = get_field('books_global', 'options'); // the global field
$combined_books = $books_single + $books_global; // the calculation
update_field( 'books_global', $combined_books, 'options'); // update the ACF field on the options page
}
Can anyone point me in the right direction here? Any help would be appreciated!