File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 88 * Passes through the value of a consent field from the source form to the target form.
99 */
1010add_filter ( 'gform_pre_render ' , function ( $ form ) {
11- // Update to the source and target consent field IDs and target form ID.
11+ // Update to the source and target consent field IDs and target form ID.
1212 $ source_consent_field_id = '4 ' ;
1313 $ target_consent_field_id = '4 ' ;
1414 $ target_form_id = '80 ' ;
1818 }
1919
2020 if ( rgget ( 'ep_token ' ) && is_callable ( 'gp_easy_passthrough ' ) ) {
21- $ entry = gp_easy_passthrough ()->get_entry_for_token ( rgget ( 'ep_token ' ) );
21+ $ token = rgget ( 'ep_token ' );
22+ $ entry = $ token ? gp_easy_passthrough ()->get_entry_for_token ( $ token ) : array ();
23+
24+ if ( empty ( $ entry ) ) {
25+ return $ form ;
26+ }
2227
2328 foreach ( $ form ['fields ' ] as $ field ) {
24- if ( $ field ->type == 'consent ' && $ field ->id == $ target_consent_field_id && $ entry[ $ source_consent_field_id . '.1 ' ] == '1 ' ) {
29+ if ( $ field ->type == 'consent ' && $ field ->id == $ target_consent_field_id && rgar ( $ entry, $ source_consent_field_id . '.1 ' ) == '1 ' ) {
2530 ?>
2631 <script type="text/javascript">
2732 document.addEventListener( 'DOMContentLoaded', function() {
28- var consentCheckbox = document.querySelector ( 'input[name=" input_<?php echo $ field ->id ; ?> .1"] ' );
33+ var consentCheckbox = document.getElementById ( 'input_<?php echo $ form [ ' id ' ]; ?> _ <?php echo $ field ->id ; ?> _1' );
2934
3035 if ( consentCheckbox ) {
3136 consentCheckbox.checked = true;
You can’t perform that action at this time.
0 commit comments