Last active
March 16, 2021 16:26
-
-
Save vfontjr/2d7e593104daf323ab3e92207d02612b to your computer and use it in GitHub Desktop.
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 | |
/* this will write the QR Code URL to the form entry */ | |
add_action( 'frmapi_post_response', 'frm_save_api_response', 10, 3 ); | |
function frm_save_api_response( $response, $entry, $form_action ) { | |
/* convert the response to a PHP object */ | |
$results = json_decode($response['body']); | |
/* get the results code */ | |
$code = $response['response']['code']; | |
/* get the qr code url */ | |
$qr_url = $results->result->qr; | |
/* get the form id */ | |
$form_id = $entry->form_id; | |
/* get the right field for the form | |
* this code is designed to run on two different forms | |
*/ | |
$field_id = ($form_id == '6' ) ? 125 : 123; | |
if ( $code == 200 ) { | |
FrmProEntryMeta::update_single_field( array( | |
'entry_id' => $entry->id, | |
'field_id' => $field_id, | |
'value' => $qr_url, | |
)); | |
} | |
} |
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 | |
/* warning: do not run this code without the kint debugger installed | |
* it will crash your site | |
*/ | |
/* this will write the QR Code URL to the form entry */ | |
add_action( 'frmapi_post_response', 'frm_save_api_response', 10, 3 ); | |
function frm_save_api_response( $response, $entry, $form_action ) { | |
d($response); | |
d($entry); | |
ddd($form_action); | |
/* convert the response to a PHP object */ | |
$results = json_decode($response['body']); | |
/* get the results code */ | |
$code = $response['response']['code']; | |
/* get the qr code url */ | |
$qr_url = $results->result->qr; | |
/* get the form id */ | |
$form_id = $entry->form_id; | |
/* get the right field for the form | |
* this code is designed to run on two different forms | |
*/ | |
$field_id = ($form_id == '6' ) ? 125 : 123; | |
if ( $code == 200 ) { | |
FrmProEntryMeta::update_single_field( array( | |
'entry_id' => $entry->id, | |
'field_id' => $field_id, | |
'value' => $qr_url, | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment