I receive the same error, but only when I am logged in. The Google statistics are updated.
I don’t see the error on your site (but I am not logged in there 🙂 )
Yes, the error only occurs when you ‘view’ the site from the Dashboard. Not when you go directly to the site.
I have recreated the error message in a test site:
http://collaborativecom.com/WordPressTesting/wp-admin
username: testing
pw: MFRtcr3m0neM47x5
Plain jane sterile WP install with just the GA plugin. If you log in and then view the site you will see this error message: /google-analytics-for-wordpress/frontend/class-frontend.php on line 57
Very weird!
Cat
(@catscholz74)
what is the latest on this?
I thought that I had found a bugfix earlier today, but it didn’t work. :/
The error seems to be in line 57 of frontend/class-frontend.php:
if ( in_array( $current_user->roles[0], $this->options['ignore_users'] ) ) {
As the bug doesn’t seem to affect site visitors, I’m waiting for an “official” solution.
It is purely Frontend for any user logged into your wordpress site.
But if you want to get rid of it this is what I did.
Comment out lines 56-64 of class-frontend.php
//if ( isset( $this->options['ignore_users'] ) ) {
// if ( in_array( $current_user->roles[0], $this->options['ignore_users'] ) ) {
// return false;
// } else {
// return true;
// }
//} else {
// return true;
//}
Same issue here. WP 4.01, GAbY 5.1.3
I have domens, where everything works fine, but one of them not.
After to record UA occurred error message described above.
Cat
(@catscholz74)
thanks @rktdwg – commenting out those lines fixed it. I assume Yoast will be fixing this in the next update…
What is going on here is that the expected value of
$this->options['ignore_users']
Is an array (the data type) while the actual value is “array” (the 5-character string). There is no case set up to handle the variable in question being instantiated but not containing array-type data.
A quick and dirty fix (that doesn’t involve commenting out potentially functional logic) would be replacing the following code block (starting at line 56 of wp-content/plugins/google-analytics-for-wordpress/frontend/class-frontend.php):
if ( isset( $this->options['ignore_users'] ) ) {
if ( ! empty( $current_user->roles ) && in_array( $current_user->roles[0], $this->options['ignore_users'] ) ) {
return false;
} else {
return true;
}
} else {
return true;
}
With this code-block:
if ( isset( $this->options['ignore_users'] ) ) {
if ( is_array($this->options['ignore_users'] ) ) {
if ( ! empty( $current_user->roles ) && in_array( $current_user->roles[0], $this->options['ignore_users'] ) ) {
return false;
} else {
return true;
}
} else {
return true;
}
} else {
return true;
}
Which causes it to not only check if $this->options['ignore_users'] is set, but also if it contains proper array-format data.
It should be noted that the aforementioned fix entirely bypasses deeper questions of what’s causing the faulty data in the variable.
This was fixed in GA 5.1.4.
Just a note to say I still had this issue after upgrading to 5.1.4.
To rectify the problem I had to have at least one user group in the ‘Ignore users’ option.
The problem returns if you remove the user groups.
I also have still this issue after upgrade!
@castor: thank you, this did the trick for me too!
hi,
unfortunately issue is still also here after update.
Issue is still here after update but when following Castor’s instructions it works great!
In the latest release I found that the warning can be eliminated by replacing this code block (beginning on line 56 of frontend/class-frontend.php):
if ( isset( $this->options['ignore_users'] ) ) {
if ( ! empty( $current_user->roles ) && in_array( $current_user->roles[0], $this->options['ignore_users'] ) ) {
return false;
}
}
With the following code block:
if ( isset( $this->options['ignore_users'] ) ) {
if ( is_array( $this->options['ignore_users'] ) ) {
if ( ! empty( $current_user->roles ) && in_array( $current_user->roles[0], $this->options['ignore_users'] ) ) {
return false;
}
}
}