1

Would modify the action of Contact Form 7 once sent the mail.

I follow this post and woks fine. But my fom is in a Bootstrap Modal, and I wish they would keep open on submit.

My code is. In function PHP

add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url'); function wpcf7_custom_form_action_url() {  return 'http://saviacomunicacion.com.ar/test2014#sala-de-prensa'; }

And in the Aditional Settings field

add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');

This redirect the URL, but it´s not sending the mail. I wish i could send the mail and keep the modal open to show the response: Your mail was send correctly.

Thanks

Community
  • 1
  • 1
Estudio 3551
  • 170
  • 3
  • 14

2 Answers2

1

According to the doc there is another way to accomplish the redirect. Just add some piece of code to the plugin dashboard. Or you can do custom js function

in the plugin options

on_sent_ok: "customFunction();"

and somewhere in the code

<script>
    function customFunction() {
        // show your modal here
        $('#myModal').modal();
    }
</script>
iurii
  • 4,142
  • 2
  • 23
  • 28
  • Not working, the page still reload, i want to send mail and keep modal show, but without reloading the page. I tried with this `j(document).on('mailsent.wpcf7', function (event) { event.preventDefault(); j('#urlModal').modal(); });` But not working – Estudio 3551 May 21 '15 at 14:29
0

I found my solution with this code. When form submit, the Modal closes after 1 second. Instead of keeping Modal open, i wait 1 second after close, to show the response of the sending.

j(".form-horizontal").live("submit", function(){
        j.post(this.action, j(this).serialize(), function(){
            //this callback is executed upon success full form submission close modal here

        }, "script");
     //this is to wait 1 second until close
        setTimeout(function() {j('.modal').modal('hide');}, 1000);          
        return false;
    });
Estudio 3551
  • 170
  • 3
  • 14