added redirection without need of a page, use it for paypal success or failure message already
This commit is contained in:
@@ -113,11 +113,13 @@ CIPF_admin_activation_prof
|
||||
/*
|
||||
* ABORTED
|
||||
* tried to receive the form in ajax from front with wp REST API
|
||||
* but then I'm not sure how to handle the front
|
||||
* but I cannot verify if the user is logged in
|
||||
* so it does not work
|
||||
*
|
||||
*/
|
||||
function admin_validate_prof_form_CIPF($request) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
|
||||
error_log("-----");
|
||||
error_log("inside admin_validate_prof_form_CIPF");
|
||||
error_log("request");
|
||||
@@ -126,19 +128,23 @@ function admin_validate_prof_form_CIPF($request) {
|
||||
error_log(json_encode($_POST));
|
||||
// _POST : {"field_title":["\u00c9tat du compte"],"field_name":["compte-actif"],"field_id":["cipf_admin_activate_prof"],"form_key":"40781-1","unique_id":"91eed9aa-2b92-4da7-a0b4-e94f24515223","form_type":"custom","divi-form-submit":"yes","form_id":"","form_type_confirm":""}
|
||||
|
||||
// maybe do a redirection here ?
|
||||
// with wp_safe_redirect(home_url('/slug')); ?
|
||||
// return new WP_REST_Response( array( 'message' => 'Form submitted successfully' ), 200 );
|
||||
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
|
||||
nocache_headers();
|
||||
$redirect_url = home_url() . '/' . $slug_page_redirection;
|
||||
wp_redirect($redirect_url, 301);
|
||||
exit;
|
||||
}
|
||||
function endpoint_form_admin_activate_prof_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$base_rest_route = PLGNTLS_class::BASE_REST_ROUTE;
|
||||
$base_rest_route = PLGNTLS_class::URL_BASE_REST_ROUTE;
|
||||
|
||||
register_rest_route($base_rest_route, '/admin_prof_activate_form', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => 'admin_validate_prof_form_CIPF',
|
||||
));
|
||||
};
|
||||
add_action('rest_api_init', 'endpoint_form_admin_activate_prof_CIPF');
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user