-
Notifications
You must be signed in to change notification settings - Fork 90
gppa-force-gppa-on-save-and-continue.php
: Added snippet to force GPPA value over a Save & Continue Value.
#597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
gppa-force-gppa-on-save-and-continue.php
: Added snippet to force GPPA value over a Save & Continue Value.
#597
Conversation
…PA value over a Save & Continue Value.
…PA value over a Save & Continue Value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I'm digging the direction.
Just a few notes from me. (Also seeing PHPCS issues).
To do our diligence, did you first try the gppa_should_force_use_field_value
filter?
$target_form_id = 29; | ||
$target_field_id = 1; | ||
static $_gppa_forcing_hydration; | ||
if ( $form['id'] == $target_form_id && ! $_gppa_forcing_hydration ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a check for the field ID here? You might need to introduce a foreach as being able to specify multiple fields would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha!
$_gppa_forcing_hydration = true; | ||
$submission = json_decode( $submission_json, ARRAY_A ); | ||
$field = GFAPI::get_field( $form, $target_field_id ); | ||
$hydrated_field = gp_populate_anything()->hydrate_field( $field, $form, array(), null, false ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing array()
for field values, it might be helpful to pass the draft entry that way if something relies on another field's value to populate, it'll populate correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha!
@claygriffiths before I update on the current snippet. Here's the other one:
I tried with this snippet using the filter |
@saifsultanc Got it! This is good to have on record. I'm cool with going forward with what you have in this PR. |
…PA value over a Save & Continue Value.
…PA value over a Save & Continue Value.
Thanks @claygriffiths . Multiple target field support updated. Loomo ~45 sec : https://www.loom.com/share/d0aebbe72b0f426887884ad6c33c91f7 |
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/2099104029/41936?folderId=3808239
Summary
When resuming a Save & Continue session, GPPA-populated fields correctly honor the Save & Continue value. This snippet would force GPPA to repopulate the field, ignoring the Save & Continue value.
The snippet in Action: https://www.loom.com/share/6ccde3a615234810b086a41f3c029f2d