开发者

Wordpress Contact Form plugin stuck loading forever when sending a form

开发者 https://www.devze.com 2023-01-13 19:57 出处:网络
In this page, I\'m using the Contact Form 7 plug in (at the very bottom). When I fill the form and press send the form stay loading forever.

In this page, I'm using the Contact Form 7 plug in (at the very bottom).

When I fill the form and press send the form stay loading forever.

Any suggestions?

code:

<p>您的姓名 〈需填寫〉<br />
    [text* your-name] </p>

<p>您的電子郵件信箱 〈需填寫〉<br />
    [email* your-email] </p>

<p>主旨<br />
    [text your-subject] </p>

<p>您的信件內容<br />
    [textarea your-message] </p>

<p>[submit "傳送"]</p>

(there's isn't really too much code since is a Wordpress plugin).

I'm using Wordpress 3.0.1 and Co开发者_如何学Gontact Form 7 (3.3.1)


Step:1

Go to ftp:

wp-content/plugins/contact-form-7/contact-form-7.php

In contact-form-7.php

Step:2

Find:

if ( ! defined( 'WPCF7_LOAD_JS' ) )
    define( 'WPCF7_LOAD_JS', true);
Replace:
if ( ! defined( 'WPCF7_LOAD_JS' ) )
    define( 'WPCF7_LOAD_JS', false );

upload your file and Try it done.


Try another contact form plugin to see if you can send any email at all. Check your webhost error logs for php errors.

Use the developer tools in your browser to check for Javascript errors. Contact Form 7 uses javascript for some of the form processing, and you may have a Javascript conflict.

The issue might be a server problem. Ask your webhost if there are issues using php mail. Try sending an email manually using php mail; see How to send an email using PHP?

Also, try WordPress › WP Mail SMTP « WordPress Plugins which allows you to test send email via SMTP and will show a log of server actions and which will let you possibly find the issues.


Since I don't want to edit any plugin files I went with the filter options:

// WPC7 forms were not submitting, this fixes that
add_filter( 'wpcf7_verify_nonce', '__return_true' );
add_filter( 'wpcf7_load_js', '__return_false' );


It might be conflict with other plugins, like another contact form? In my case I was using MMForms-Community and Contact Form 7 is the reason.. So in other words, I can not use both as they conflict with each other from WP version 3.0 and up.


Editing contact-form-7.php as mentioned above helped but my emails would not arrive in my inbox, but they were in my sent box.

Similar to my configuration:

  • Google Cloud for hosting WordPress (WP)
  • Google’s G Suite for email (smtp.gmail.com)
  • Contact Form 7 - WP Plugin
  • Postman SMTP - WP Plugin
  • Main email - John-Doe@example.com
  • Alias email - info@example.com

I was able to get the emails to my inbox by using the main-email account in the From location in Postman SMTP instead of the gmail alias because the main was needed for authentication.

Worked: From: John-Doe@example.com To: info@example.com
Did not work: From: info@example.com To: info@example.com

The text below is from the chat session with Google’s Support.
The reason why you have to use a different domain is because the web forms get confused and try to deliver the email at your web host rather than your mail host, they see your domain in the recipient and say "hey this is the same domain where the site is hosted at, it should be the same, lets save some effort looking at the domain’s MX records and lets leave it right here". The From: field needs to be your primary email address since it requires authentication (aliases can’t authenticate), the TO: field has to be preferably an email not from your domain name, like the test alias example.com.test-google-a.com. If you are sending it from a website is different, the behavior when it gets dropped is just when you use Gmail web mail or a mail client. For web forms, send the emails to the aliases from the test example.com.consulting.test-google-a.com.


I want to add to VijaiJerald's answer. That particular solution didn't work for me, but it did work when I changed as he proposed:

if ( ! defined( 'WPCF7_LOAD_JS' ) ) {
    define( 'WPCF7_LOAD_JS', true);
}

Replace with:

if ( ! defined( 'WPCF7_LOAD_JS' ) ) {
    define( 'WPCF7_LOAD_JS', false );
}

But also the following line:

if ( ! defined( 'WPCF7_VERIFY_NONCE' ) ) {
    define( 'WPCF7_VERIFY_NONCE', false);
}

Replace with:

if ( ! defined( 'WPCF7_VERIFY_NONCE' ) ) {
    define( 'WPCF7_VERIFY_NONCE', true );
}

I also want to note that literally no other solution worked for me (disabling all plugins, changing the WP_DEBUG value, resetting the browser, reinstalling Wordpress, updating and upgrading all plugins, disabling all custom CSS and JavaScripts, etc...) so this might help people that have this issue. I also want to note that while it wasn't working on my laptop (tried multiple browsers), I didn't had this issue on my phone at all.


Usually infinite loading is caused by a problem in your theme. You can overwrite the style/code of Contact Form 7 with javascript and a piece of css. You can solve this problem with the following piece of javascript:

document.addEventListener( 'wpcf7submit', function( event ) {
   jQuery('head').append('<style type="text/css">.aw-no-spinner:before{display:none!important}</style>');
   jQuery('body').find('.processing').addClass('aw-no-spinner');
}, false );
jQuery('.wpcf7-submit').on('click', function( event ) {
   jQuery('body').find('.processing').removeClass('aw-no-spinner');
});

In this example we use the built-in hook of contact form 7: wpcf7submit

When this event is fired then our piece of code is executed. This piece of code adds an extra class to the loading wrapper of contact form 7. And also we add a piece of css to the head so we don't have to put this in a separate CSS file.

We have also incorporated this solution into a WordPress plugin for users who prefer not to add code to their website or do not have a child theme.

This is the link to the plugin, but you can also use the piece of code described above. https://wordpress.org/plugins/awcf7-stop-spinning/

0

精彩评论

暂无评论...
验证码 换一张
取 消