New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not remove user role value from roles property. #27
Conversation
Hi @oscarssanchez, I encountered the same issue. I've confirmed that this fixes it. Is there a reason to use |
Hi @nylen , Thanks for helping us testing this one. The logic was to follow the However, it seems the reason it's used must be to just extract that value. If so, I think accessing the property the way you suggested is indeed more straightforward. I updated the PR. Thanks again! |
classes/class-wp-nr-apm.php
Outdated
@@ -85,7 +85,7 @@ public function set_custom_variables() { | |||
if ( function_exists( 'newrelic_set_user_attributes' ) ) { | |||
if ( is_user_logged_in() ) { | |||
$user = wp_get_current_user(); | |||
newrelic_set_user_attributes( $user->ID, '', array_shift( $user->roles ) ); | |||
newrelic_set_user_attributes( $user->ID, '', $user->roles[0] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we verify that the index of [0] actually exists? Just in case the roles are hosed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @allan23 , I updated the PR :)
Thanks @oscarssanchez and @allan23! Will there be a release to the plugin directory to address this issue, or should we update the plug-in from this repo for now? |
@nylen this is live on wp.org. Be sure to upgrade to 1.3. |
Hi @allan23 , could you please review this PR which addresses #25 ?
It seems that by using
array_shift()
to retrieve the first element of the roles property we are taking away this value, so the property ends up empty and it causes the user to not have any rolesThanks.