Skip to content

Instantly share code, notes, and snippets.

@vfontjr
Last active March 16, 2021 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vfontjr/2d7e593104daf323ab3e92207d02612b to your computer and use it in GitHub Desktop.
Save vfontjr/2d7e593104daf323ab3e92207d02612b to your computer and use it in GitHub Desktop.
<?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,
));
}
}
<?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