Sjors
Forum Replies Created
-
I tried, but failed, incorporating your suggestion in the functions.php, the class-api.php.
More help would be appreciated.
This is how far I came with the help of ChatGPT:
class Api {
public function __construct() {
// ? Register the filter on class initialization
add_filter( 'gutenverse_form_format_data', array( $this, 'process_form_data' ), 10, 6 );
}
/**
* Process Form Data and Trigger Bit Integrations Hook
*
* @param string $data_html The form's HTML data.
* @param int $form_id The ID of the form.
* @param array $form_entry The submitted form entry data.
* @param int $entry_id The ID of the form entry.
* @param bool $admin Whether in admin context.
* @param array $extra Extra arguments if any.
*
* @return string Processed $data_html.
*/
public function process_form_data( $data_html, $form_id, $form_entry, $entry_id, $admin, $extra ) {
// ?? Process form entry data if needed
foreach ( $form_entry['entry-data'] as $data ) {
// Example: log or validate $data here
}
// ? Trigger Bit Integrations hook
do_action(
'bit_integrations_custom_trigger',
'0a0a0c4d-6ab7-467d-aec4-5de4b7703ba4', // Your Bit Integrations ID
array(
'form_id' => $form_id,
'entry_id' => $entry_id,
'form_entry' => $form_entry,
)
);
// Return the original or modified $data_html
return $data_html;
}
/**
* Submit Form Method
*/
public function submit_form( $request ) {
$form_entry = $request['form-entry'];
$form_data = $this->filter_form_params( $form_entry['data'] );
$form_id = $form_entry['formId'];
$is_login = is_user_logged_in();
$form_setting = get_post_meta( (int) $form_id, 'form-data', true );
if ( isset( $form_data ) ) {
$params = wp_parse_args(
array(
'form-id' => (int) $form_entry['formId'],
'post-id' => (int) $form_entry['postId'],
'entry-data' => $form_data,
'browser-data' => $this->get_browser_data( $form_entry ),
)
);
$result = array( 'entry_id' => Entries::submit_form_data( $params ) );
// ?? Apply the filter here (this triggers your custom logic)
apply_filters(
'gutenverse_form_format_data',
'', // $data_html
$form_id, // $form_id
$params, // $form_entry
$result['entry_id'], // $entry_id
false, // $admin
array() // $extra
);
}
return rest_ensure_response( $result );
}The emails are transmitted and all. I have followed the instructions and that is working. That is not the issue. I would like to use the form data that is stored in the entries part/table to be synchronised or imported in the Brevo database. This way I can use them for email marketing and other workflows supported by Brevo.
However I would like some more help in relation to getting the raw data. Or how to include a?do action hook in your form submitting function so that I can use something like Bit Integrations.
For example:do_action(
‘bit_integrations_custom_trigger’,
‘210a16f4-7fcd-4389-a7fe-84fc509ac23a’,
array()
);The problem was indeed a conflict with Jetpack Boost.