Created
April 6, 2020 00:12
-
-
Save spivurno/a80d7ac9d3bb62aa0febe86af7b93f8f to your computer and use it in GitHub Desktop.
Gravity Perks // Populate Anything // Force Dynamic Population When Editing via Gravity View
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Gravity Perks // Populate Anything // Force Dynamic Population When Editing via Gravity View | |
* http://gravitywiz.com/documentation/gravity-forms-populate-anything/ | |
*/ | |
add_filter( 'gravityview/edit_entry/field_value', function( $field_value, $field ) { | |
// Update "123" to your form ID and "4" to your field ID. | |
if ( $field->formId == 123 && $field->id == 4 ) { | |
if ( isset( $GLOBALS['gppa-field-values'] ) ) { | |
$hydrated_field = gp_populate_anything()->hydrate_field( $field, GFAPI::get_form( $field->formId ), array(), null, false ); | |
$field_value = $hydrated_field['field_value']; | |
} | |
} | |
return $field_value; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👉 This Gist has been migrated to the Gravity Wiz Snippet Library:
https://github.com/gravitywiz/snippet-library/blob/master/gp-populate-anything/gppa-force-dyn-pop-on-gv-edit.php