• Resolved willlweb

    (@willlweb)


    Hi there,

    I’m hoping to alter the redirect URL based on the actual form submission or something else on the page…For example if a certain option is selected in a dropdown.

    Is there any filter that will allow me to run to alter the form args just before the form submits so the URL can be manipulated?

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi!

    There is no filter to edit the args after a form has been submitted (that could potentially mess with a few things). The way I would do this is to simply hook into the af/form/submission action and trigger your own redirect using wp_redirect!

    Here’s an example of redirecting if a certain field is a certain value:

    
    function redirect_after_form_submission() {
      $field_value = af_get_field( 'field_name' );
    
      if ( 'REDIRECT' == $field_value ) {
        wp_redirect( 'https://google.com', 302 );
      }
    }
    add_action( 'af/form/submission/key=FORM_KEY', 'redirect_after_form_submission' );
    

    Don’t forget to replace FORM_KEY with your form key. ??

Viewing 1 replies (of 1 total)
  • The topic ‘Redirecting based on form selection’ is closed to new replies.