Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter thomasjarvisdesign

    (@thomasjarvisdesign)

    This problem was also reported here without a solution:
    https://wordpress.org/support/topic/js-error-wpcf7-is-not-defined/ The issue is the same. But without the Multistep plugin enabled.

    Thread Starter thomasjarvisdesign

    (@thomasjarvisdesign)

    This solution works: But if you can provide an update to the documentation on the website it would br really appreciated.

    ‘function contactform7_dequeue_scripts() {
    $check_cf7 = false;

    if( is_page(‘contact’) ) {
    $check_cf7 = true;
    }

    if( !$check_cf7 ) {
    wp_dequeue_script( ‘contact-form-7’ );
    wp_dequeue_style( ‘contact-form-7’ );
    }
    }
    add_action( ‘wp_enqueue_scripts’, ‘contactform7_dequeue_scripts’, 77 );’

    I was having the same issue, thanks for the fix @thomasjarvisdesign

    Thread Starter thomasjarvisdesign

    (@thomasjarvisdesign)

    @screenres No problem. Feel sorry for me I had to roll this fix out to 60 websites manually….

    YOu can change the if is page to an array if you want to include multiple pages.

    I also added dequeue for contact form 7 conditional fields plugin.

    // Function to enable CF7 on certain pages
    function contactform7_dequeue_scripts() {
        $check_cf7 = false;
    
        if( is_page ( array ('contact', 'contact-us', 'pre-booking-form') ) ) {
            $check_cf7 = true;
        }
    
        if( !$check_cf7 ) {
            wp_dequeue_script( 'contact-form-7' );
            wp_dequeue_style( 'contact-form-7' );
            wp_dequeue_script( 'wpcf7cf-scripts' );
            wp_dequeue_style( 'cf7cf-style' );
        }
    }
    add_action( 'wp_enqueue_scripts', 'contactform7_dequeue_scripts', 77 );

    @thomasjarvisdesign 60 sites!
    Thankfully I haven’t got that many to update.
    CF7 Condition Fields still worked fine for me with the standard method but suppose I should keep it all neat in one call in one place.
    Thanks for the updated.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Bug: wpcf7 JQuery Not Defined Error’ is closed to new replies.