WordPress.org

Ready to get started?Download WordPress

Forums

Google Analytics for WordPress
Fatal error with Multi-site network activation (4 posts)

  1. johnzhel
    Member
    Posted 2 years ago #

    When I activate this plugin in WordPress (MU) Network Admin as "Network Activate", all sub-blogs become non-accessable with an error:

    Fatal error: Call to a member function set_defaults() on a non-object in /home/myaccountname/public_html/EXAMPLE.COM/wp-content/plugins/google-analytics-for-wordpress/googleanalytics.php on line 1517

    It is because this plugin does not "by default" select a Analytics Profile to use, which causes a fatal error.

    That said, now, I set the default as "Manually enter your UA code" box checked, and the "Manually enter your UA code" text field prefilled with main site's UA code. After that change, every new sub log does not show the fatal error any more.

    Now, my problem is how to have each sub blog created with the main site UA code activated by default.

    As I wrote earlier, I can make the plugin to check the "manually" box and prefill a UA code, but I do not know how to automatically "click" the "Update Google Analytics Settings" to save and make this settings take effect by itself.

    Does anyone know how?

    Thanks and look forward to your solutions :)

    http://wordpress.org/extend/plugins/google-analytics-for-wordpress/

  2. johnzhel
    Member
    Posted 2 years ago #

    By the way, what I did was:

    in googleanalytics.php

    Line 423 (replace '.$options['uastring'].' with a UA code)

    $line = '<div id="uastring_automatic">'.$line.'</div><div style="display:none;" id="uastring_manual">Manually enter your UA code: <input id="uastring" name="uastring_man" type="text" size="20" maxlength="40" value="PRE-FILL A UA CODE HERE"/></div>';

    Line 429 (swap true and false)
    'desc' => '<input type="checkbox" name="manual_uastring" '.checked($options['manual_uastring'], false ,true).' id="switchtomanual"/> <label for="switchtomanual">Manually enter your UA code</label>',

    The question is how to save this setting in sub blogs automatically when each sub blog is created.

  3. mrunkel
    Member
    Posted 2 years ago #

    I just posted about this same issue. A cleaner (to my mind) fix is to make sure that $ga_admin is defined as an object on line 1517.

    add $ga_admin = new GA_Admin; on the line before $ga_admin->set_defaults(); and you won't have the crash any more without having to force a default tracking code.

  4. afswp
    Member
    Posted 2 years ago #

    I had the same issues. I deactivate all plugins and used the wp 2010 theme and nothing worked. I activated everything and it continued to not work. I even tried older versions of the plugin.

    It wasn't until I activated the plugin at the site level the fatal error went away.

    Have a great day.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic