• Resolved branislavmeandzija

    (@branislavmeandzija)


    Since update to 6.0 from 5.9.8 i am getting this JS error that prevents contact form 7 JS from being executed, form is visible and php is working correctly but there is no validation at all due to plugin js error.

    Console error : wpcf7 is not defined.
    (anonymous) @ index.js?ver=6.0:1

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    What other plugins and theme do you use on the site?

    Thread Starter branislavmeandzija

    (@branislavmeandzija)

    This is the current list of active plugins, all on the lastest versions, theme is custom developed:

    ActiveCampaign Postmark

    Advanced Custom Fields Multilingual

    Advanced Custom Fields PRO

    Contact Form 7

    Contact Form 7 Extension For Mailchimp

    Contact Form 7 Multilingual

    Contact Form CFDB7

    GDPR Cookie Compliance

    Git UpdaterVersion

    Safe SVG

    Transients ManagerVersion

    WPML Media Translation

    WPML Multilingual CMS

    WPML SEO

    WPML String Translation

    Yoast SEOVersion

    Yoast SEO Premium

    Anyways, i did a bit of testing, disabled all the plugins and got a same result on the same theme, when i switched the theme to default wp theme it seems like index.js is loaded correctly and validation is working, so it’s safe bet that some part of our custom code functionality causes this error, any idea which change from 5.9.8 to 6.0 would cause this error so i can troubleshoot our code further? This is currently the way we echo form in php:

      <?php if (!is_admin() && isset($form) && $form) : ?>
      <?= do_shortcode('[contact-form-7 id="' . $form->ID . '" title="' . $form->post_title . '"]'); ?>
      <?php endif; ?>
    Thread Starter branislavmeandzija

    (@branislavmeandzija)

    The issue was in this piece of code defering wpcf7 js files on the load, so probably that was the reason wpcf7 was declared as undefined:

    add_filter( ‘script_loader_tag’, function ($tag, $handle, $src) {
    if(!is_admin()) {
    $tag = ”.”\n”;
    }
    return $tag;
    }, 10, 3 );

    bipolab

    (@bipolab)

    Hello,
    could you kindly explain it better (and how you have fixed it)?

    Thread Starter branislavmeandzija

    (@branislavmeandzija)

    @bipolab Well i guess they changed how the validation works now, at least what i am sure off is that wpcf7 scripts are being required to be loaded immediately for initialization of wpcf7 object, so in my case i have been using that filter above that actually deferred wpcf7 js scripts and that was causing wpcf7 object to be undefined. If you are having the similar issue it’s probably because that wpcf7 js script are being deferred, i would suggest you to check the source code on the page and look for wpcf7 script being correctly inserted on the page without being deferred. In my case i just had to remove this filter from functions.php or to add a check for specific id of the scripts and exclude it from deferring.

    Thank you for your replay.
    The issue is giving us problems with iubenda…
    I’ll try your suggestion as soon as our boss will give the ok to preceed ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.