I have a problem with my implementation of a custom action on form submission. The action code I define runs with no issues, the AJAX response returns a status 200, but its content is always the following:
{ "success": false, "data": { "action": "my_custom_action", "type": "error", "message": "A submiss\u00e3o falhou. Por favor, recarregue a p\u00e1gina e tente enviar o formul\u00e1rio novamente." } }
In my code snippet, I have defined the form result using set_result(), as I thought this would result in a “success: true” response. I doubt this is a bug, I just want to know if there is any specific return that the function I defined should perform.
This is my code, which currently doesn’t have a specific return:
function form_vote_submission_action( $form ) {
global $wpdb;
// Implementation logic
error_log("INFO: Finishing. Success.");
$form->set_result([
'action' => 'my_custom_action',
'type' => 'success',
'message' => esc_html__('Please check your email to confirm the submission.', 'bricks'),
]);
}
add_action( 'bricks/form/custom_action', 'form_vote_submission_action', 10, 1 );