Contact Form 7 Bypass Solution
-
Hi Jeff,
Happy holidays ??You know that thing when “a new problem” occurs and googling directs to your own post / writing lol?
related topics:
https://www.ads-software.com/support/topic/contact-form-7-non-sending-emails/
https://www.ads-software.com/support/topic/contact-form-7-dont-work-with-disabled-rest-api/Yeah, I noticed in error logs that CF7 failed, and given the errors, this plugin was the main suspect. It was 1.5 years ago when I fixed this with a patch, and you should just ask me what it was back then (haven’t noticed further topics and conversations), because it was a very simple patch.
I didn’t originally post a solution here, because it was a very simple one, and I thought it would be added as an option in the plugin’s settings, because not everyone needs / wants it (e.g. CF7 is not used by everyone).
Problem: CF7 not sending emails
jquery.min.js:2 POST https://.../wp-json/contact-form-7/v1/contact-forms/.../feedback 401 (Unauthorized) jquery.min.js:2 XHR failed loading: POST "https://.../wp-json/contact-form-7/v1/contact-forms/.../feedback". rest api response {"code":"rest_login_required","message":"REST API restricted to authenticated users.","data":{"status":401}}
Solution is simple like this:
in function disable_wp_rest_api() change the line from:
if (!is_user_logged_in()) {
to this:
if ( !is_user_logged_in() && empty($_POST['_wpcf7']) ) {
It does not check any security tokens.
Hopefully, you’ll add this in the future, because with each update it stops working, and that could be very bad for many users, unless they apply this patch.
Thanks!
RegardsThe page I need help with: [log in to see the link]
- The topic ‘Contact Form 7 Bypass Solution’ is closed to new replies.