Hi Arne,
This conversion is handled by PHP’s json_encode function, and is automatically reverted when you json_decode the string value.
Instead of using a trigger in SQL, perhaps it’s more useful for you to hook into hf_form_success instead? From there, saving the submission (or only the data you need) would look something like this:
add_action( 'hf_form_success', function( $submission, $form ) {
global $wpdb;
$wpdb->insert( 'my_table', array( 'name' => $data['NAME'] ) );
}, 10, 2 );
Hope that helps. If not, let us know please.
Thanks for your quick answer!
This is probably a better solution, yes.
(The only drawback is may be that it will not support for instance importing data and WordPress restores which a trigger would).
As I am new to WordPress and using such hooks I hope you can provide me with some more information or may be a link to a how to.
Should I add this action to src/Actions/Action.php?
Inside public function hook()?
Hi again!
I tried the setup above but have one challange:
$data is NULL
$submission is blank
$form just gives me the html-form, not the data
So what am I doing wrong?
add_action( ‘hf_form_success’, function( $submission, $form ) {
global $wpdb;
$wpdb->insert( ‘Loppehenting’, array( ‘Kommentar’ => $submission, ‘Hva’ => $form ) );
}, 10, 2 );
}