Where can we see the website in question?
What other plugins and theme do you use on the site?
@takayukister plugins installed:
- Contact Form 7
- WP Cerber Security, Anti-spam & Malware Scan
- WP Change Default Email
- WP Mail SMTP
- Yoast SEO
Theme: Self-developed theme, which I use on another site and on that one the recaptcha works ok.
PHP version on server: 8.3 FPM
WP version: 6.6.1
I have the same version on other sites and it adds the recaptcha code and the form works fine.
That’s why I can’t find a way to fix it.
Thanks for your help.
Try switching to the default theme, deactivating all plugins excluding Contact Form 7, WP Mail SMTP and Yoast SEO, and clearing all cache data.
Why you are advised to deactivate plugins and switch to the default theme.
@takayukister Thanks for your reply.
II’ve been looking and found that the error occurs because it doesn’t load the CF7 JS on the web.
Do you know what could be stopping it from loading the scripts?
The strange thing is that the CF7 CSS does load, for example:
<link rel="stylesheet" id="contact-form-7-css" href=/wp-content/plugins/contact-form-7/includes/css/styles.css?ver=5.9.8" media="all">
Load on the source code, but not all the CF7 JS javascripts, that’s why the recaptcha doesn’t work.
For example, this script doesn’t load:
<script src="/wp-content/plugins/contact-form-7/modules/recaptcha/index.js?ver=5.9.8" id="wpcf7-recaptcha-js"></script>
among others.
Is there a way to force the loading of the scripts?
I tried with this code that I found, but it’s still the same:
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );
add_action('get_header', 'load_wpcf7_scripts');
function load_wpcf7_scripts() {
if ( is_page() ) {
if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
wpcf7_enqueue_scripts();
}
if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
wpcf7_enqueue_styles();
}
}
}