I am using native Gravity Forms to create posts.
I am using Gravity Forms + Custom Post Types to handle creating custom post type posts. This works great.
Its been about 3 years since i’ve had to create/update posts in a wordpress project using Gravity Forms. Back then it was super easy to update posts using Gravity Forms: Post Updates
It was so simple, just add update
to the end of the Gravity Form shortcode…
[gravityform id="2" title="false" description="false" ajax="true" update]
…and voila, the form would get all the current post data/custom fields and automatically map each Gravity Form post field and pre-renders each input with the current post data. When you save the form, it would update the current post instead of creating a new one. Job done.
Anyway, Gravity Forms: Post Updates no longer works because its not been updated in 4 years and upon installation in WordPress 5.2.1, it throws a fatal error.
Plugin could not be activated because it triggered a fatal error.
Fatal error: Cannot use lexical variable $value as a parameter name in
../wp-content/plugins/gravity-forms-post-updates/gravityforms-update-post.php
on line 1021
Thats spooned it so what is an alternative solution?
I don’t want to have to custom code each field with a custom function using gform_pre_render
and gform_after_submission
filters/actions.
Please any ideas for Gravity Forms: Post Updates alternative would be awesome thanks.
1 Answer
I found a solution to fix this issue on the plugin Github page.
It’s not ideal, but a work around until Gravity Forms makes this a core feature.
https://github.com/jupitercow/gravity-forms-post-updates
To fix the error and allow the plugin to be installed, you have to change…
row 1021
in file gravityforms-update-post.php
from (version 1.2.17)…
add_filter( 'gform_field_value_' . $field['inputName'], function($value) use($value) { return $value; } );
to…
add_filter( 'gform_field_value_' . $field['inputName'], function($v) use($value) { return $v; } );
Thanks to bagendahl. So far i’ve not stumbled across any issues.
See the original Github issue thread here.
Hope this saves someone some time.