0

I’m looking for solution whole day but can’t find anything that work. So I want to automaticaly submit CF7 on page load. If I use any jQuery or JS solution there is some endless looping on the site. So any solution for my problem?

Thanks in advance

1 Answer 1

0

You need to call submit() function on document ready check the code

<script type="text/javascript">
jQuery(document).ready(function(){
     jQuery("#wpcf7-f3857-o1 form").submit();
});
</script>

In my code wpcf7-f3857-o1 is the contact form's css id. You need to change that id. try the code and let me know the result. Thanks

2
  • This cause endless looping. Page doesn't have time to render because this script submit form again and again :(
    – Karnak
    Aug 6, 2018 at 19:23
  • I'm adding this in functions-php as a shortcode and then place shortcode after cf7. add_shortcode('custom_js_for_cf7','custom_js_for_cf7'); function custom_js_for_cf7($args){ return ' <script type="text/javascript"> jQuery(document).ready(function(){ jQuery("#wpcf7-f3857-o1 form").submit(); }); </script> '; } I'm I doing something wrong?
    – Karnak
    Aug 6, 2018 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.