contact form 7 conditional redirect

  • Unknown's avatar

    Hi,

    i’m trying to create a conditional redirect for my website whereby a customer will select an option that has a value from £1000 to £2500000 and if they select an option that is less than or equal to 10000 they will be redirected to one page (page A) and if they select an option greater than 10000 they’ll be redirected to a different page (page B). i took the code from online and have been using it and it works if I set it to only recognise the contact form ID. however, the additional parameter doesn’t work and breaks the whole thing.

    there’s something I’m missing but I don’t know what – please can someone help me?

    code:

    add_action( ‘wp_footer’, ‘HPR’);
    function HPR() {
    ?>
    <script type=”text/javascript”>
    document.addEventListener( ‘wpcf7submit’, function( event ) {

    if ((event.detail.contactFormId == ‘19521’) AND (‘LoanAmount’=< 10000)){location = ‘https://finapay.co.uk/personal-loan-form’;}
    elseif ((event.detail.contactFormId == ‘19521’) AND (‘LoanAmount’ > 10000)){location =’https://finapay.co.uk/secured-loan-application/’;}

    }, false );
    </script>
    <?php
    }

    thanks in advance!

  • Hi there!

    For help with custom code, you’ll probably want to ask at https://wordpress.org/support/forums/.

    Here, on WordPress.com, custom PHP code is not permitted, so we won’t be able to help you out.

  • The topic ‘contact form 7 conditional redirect’ is closed to new replies.