Redirect to form after failed validation

Support MB Frontend Submission Redirect to form after failed validation

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #33038
    Steffen LarsenSteffen Larsen
    Participant

    How come the redirect not working when there is failed validation? Does it only work with succesful submits?

    #33050
    Long NguyenLong Nguyen
    Moderator

    Hi Steffen,

    A little bit tricky, you can add the redirect function when validating with the hook rwmb_frontend_validate. Like this

    add_filter( 'rwmb_frontend_validate', function( $validate, $config ) {
        if ( empty( $_POST['field_id'] ) ) {
            wp_redirect( 'https://facebook.com' );
            die;
        }
        return $validate;
    }, 10, 2 );
    #33136
    Steffen LarsenSteffen Larsen
    Participant

    But then the validate message doesn't show?

    I just wanna redirect to the form like this (it stays on the same site, but scrolls to the form) https://www.sikkerfangst.dk/produkt/en-ordentlig-fiskestang#auktionsbud

    Your example works, but then the message doesn't show.

    #33147
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Currently, it is not possible to redirect to a URL if the validation is not passed. I will inform the development team to explore the possibility.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.