Contact Form 7 - Uncaught TypeError: wpcf7.initForm is not a function

I updated to WordPress 5.7 and Contact Form 7 v5.4. The new version is not compatible anymore with a js file (line 6 wpcf7.initForm), that a previous developer wrote for our theme. Unfortunately I can't find a way to adapt the code so initForm get's recognized again. There are several suggestions with extra functions and I tried to copy them to different lines in the file, but the error won't disappear. Can someone please tell me, how I can correctly adapt the file to get rid of the error?

i.find(.wpcf7).each(function() {
            wpcf7.initForm(n(this).find(.wpcf7-form)[0]), this.addEventListener(wpcf7mailsent, function(n) {
                for (var t = null, e = n.detail.inputs, i = 0; i  e.length; i++)
                    if (contact-email === e[i].name) {
                        t = e[i].value;
                        break
                    }

Every help is appreciated.

Edit: If someone is facing the same issue: the solution is to replace wpcf7.initForm($form); with wpcf7.init($form[0]);. Thanks to Jules Colle at this point for the hint!

Topic plugin-contact-form-7 jquery init contact Wordpress javascript

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.