fix(07-01): add filter to set redirect URL in registration form response
- Added set_registration_redirect() filter on frm_json_response - Modifies Formidable's JSON response to include redirect_url - Formidable JavaScript will then redirect to /anbieter-dashboard/ - Fixes registration redirect issue
This commit is contained in:
@@ -162,6 +162,9 @@ class DDHH_JM_Formidable {
|
||||
// Hook into Formidable form submission
|
||||
add_action( 'frm_after_create_entry', array( __CLASS__, 'handle_registration_submission' ), 30, 2 );
|
||||
|
||||
// Add filter to set redirect URL in form response
|
||||
add_filter( 'frm_json_response', array( __CLASS__, 'set_registration_redirect' ), 10, 1 );
|
||||
|
||||
// Hook into Formidable form validation for ownership check
|
||||
add_filter( 'frm_validate_entry', array( __CLASS__, 'validate_job_ownership' ), 10, 2 );
|
||||
add_filter( 'frm_validate_entry', array( __CLASS__, 'validate_job_deactivation_ownership' ), 10, 2 );
|
||||
@@ -262,6 +265,36 @@ class DDHH_JM_Formidable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set redirect URL in form response for registration form
|
||||
*
|
||||
* @param array $response JSON response from form submission.
|
||||
* @return array Modified response.
|
||||
*/
|
||||
public static function set_registration_redirect( $response ) {
|
||||
// Only modify response if there's a form_id in the response
|
||||
if ( ! isset( $response['form_id'] ) ) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
// Check if this is the registration form
|
||||
if ( $response['form_id'] != self::get_registration_form_id() ) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
// Only redirect if the submission was successful (no errors)
|
||||
if ( ! empty( $response['errors'] ) ) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
error_log('DDHH Registration: Setting redirect in form response');
|
||||
|
||||
// Set redirect URL
|
||||
$response['redirect_url'] = home_url( '/anbieter-dashboard/' );
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle registration form submission
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user