Support » Plugin: Ninja Forms Contact Form - The Drag and Drop Form Builder for WordPress » 3.6.10 bug – Ninja Forms not loading

  • Resolved David

    (@dkomando)


    So, we use Ninja Forms on landing pages. We have a Ninja Form at the top and another before the footer. And with the new release neither form is loading.

    The bug/problem is with the JavaScript method getCookie in: /wp-content/plugins/ninja-forms/assets/js/min/front-end-deps.js?ver=3.6.10:1

    There is a const setting getCookie and there are no checks around if “front-end-deps.js” already exists or is loaded. The super quick but nasty fix for this is to change the const to var and let it set twice. However, it would be better to do some kind of check around if it exists already.
    e.g.
    (typeof getCookie === ‘function’)

    I’m not yet sure how to replicate the issue but I’m guessing it could be a namespace collision from another plugin that is setting getCookie since it’s a pretty generic method name. I will start digging deeper and reply back.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter David

    (@dkomando)

    So, it is conflicting with an old plugin named “Cookie Params” which uses a very similar “getCookie” method. Guessing the “getCookie” method was pulled and slightly modified from a Stack Overflow answer (maybe: https://stackoverflow.com/q/10730362/1681478) for your plugin and the “Cookie Params” plugin. We are no longer using this plugin and are removing it from our sites.

    My suggestion would be to rename the method to exist in the Ninja Forms namespace, something like nfGetCookie() to avoid any future conflicts. Especially, since it looks like the method was derived from Stack Overflow.

    Thanks for posting about this David – we had the same problem over here. Luckily the conflicting code was in our own child theme so I was able to change our function names.

    naturfreundeschweiz

    (@naturfreundeschweiz)

    What was the conflicting code for you exactly? Also the getCookie? We don’t have any olt plugins installed and need the ones we have.

    Hi ninanmnm, david, same problem here but don’t get it how to fix it can explain more detailed how you fix it

    Thread Starter David

    (@dkomando)

    Basically, you will need to audit any other code in your theme’s functions.php or any plugins (which is probably easier to disable one by one). You’ll need to look for a PHP method called getCookie() and you can probably do a search for “getCookie(” without the quotes, to find the code that is conflicting with the new Ninja Forms code. Once you remove the conflicting method, Ninja Forms should load again. Hopefully you understand coding, otherwise this will be pretty tough.

    A second option which is only a temporary fix and I personally would not recommend doing, would be to alter Ninja Forms code directly. This isn’t a good idea because it will get overwritten on an update.

    Ninja Forms File:
    <YOUR-SITE>/wp-content/plugins/ninja-forms/assets/js/min/front-end-deps.js

    On line 176 you will see:
    const getCookie = (cname) => {

    This can be altered and by changing ‘const’ to ‘var’ which should not break or conflict with anything else:
    var getCookie = (cname) => {

    You could probably use ‘let’ instead of ‘var’ but I know ‘var’ works.

    Again, you’re better off finding the conflicting code and not altering Ninja Forms directly!

    Hope that helps you out.

    • This reply was modified 1 year, 9 months ago by David.
    Brian

    (@briansteeleca)

    @dkomando Thanks for much for following up with your solution. I was fighting with this for the past 2 days until I found this and was able to fix my form (without touching Ninja’s plugin code).

    Plugin Contributor Justin McElhaney

    (@jmcelhaney)

    @dkomando @ninanmnm @briansteeleca @lujo9 @naturfreundeschweiz
    I’m sorry to hear you are experiencing this. Can you update your Ninja Forms plugins to their latest versions and let me know if you continue to have the same issues?

    If you are still seeing the issue, can you contact our official support (https://ninjaforms.com/contact) so we can take a closer look at your issue?

    naturfreundeschweiz

    (@naturfreundeschweiz)

    @jmcelhaney Thank you very much. With the newest version it seems to work for me!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘3.6.10 bug – Ninja Forms not loading’ is closed to new replies.