• I’m working on a plugin which, basically, register users via a CF7 and create a post for each of them.
    Everything goes pretty fine, I’m able to create new users, their capabilities, create new post.
    My function works simply via
    add_action (‘wpcf7_before_send_mail’, ‘my_registration’);
    What I need is to redirect the user to the newly created post right after the form is sent.
    I can get the new permalink from my function, but I cannot figure out how to pass it to the DOM for redirect from this point.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @patriziord

    You can use wpcf7mailsent dom event listener for this:

    
    <script>
    document.addEventListener( 'wpcf7mailsent', function( event ) {
        if ( 'FORM-ID' === event.detail.contactFormId ) {
            location = 'REDIRECT-URL';
        }
    }, false );
    </script>
    
    • This reply was modified 4 years, 10 months ago by Jainil Nagar.
    Thread Starter PatrizioRD

    (@patriziord)

    Hi Jainil, thanks for your help.

    The problem is still: how can I dinamically get the permalink created in PHP / wpcf7_before_send_mail function, using JS wpcf7mailsent event listener, in order to assign it to location = ‘REDIRECT-URL’?

    I made a lot of search on this topic in particular, to use the JS listener with a just created PHP value, but no luck.

    • This reply was modified 4 years, 10 months ago by PatrizioRD.
    • This reply was modified 4 years, 10 months ago by PatrizioRD.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Set URL redirect dinamically in wpcf7_before_send_mail’ is closed to new replies.