Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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