Created
June 5, 2025 07:59
-
-
Save aimahdi/6b760fa278da31ca0bb4b435f32d5286 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('fluentform/loaded', function ($app) { | |
$app->router->post('/submit-form', function () use ($app) { | |
try { | |
$data = $app->request->get('data'); | |
$data['_wp_http_referer'] = isset($data['_wp_http_referer']) ? sanitize_url(urldecode($data['_wp_http_referer'])) : ''; | |
$app->request->merge(['data' => $data]); | |
$formId = intval($app->request->get('form_id')); | |
$response = (new FluentForm\App\Services\Form\SubmissionHandlerService())->handleSubmission($data, $formId); | |
return $app->response->json($response); | |
} catch (FluentForm\Framework\Validator\ValidationException $e) { | |
return $app->response->json($e->errors(), $e->getCode()); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment