Skip to content

Commit

Permalink
Make sure ->roles[0] exists
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarssanchezz committed Aug 30, 2018
1 parent 4757dca commit 50f6767
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion classes/class-wp-nr-apm.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ 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, '', $user->roles[0] );
if ( isset( $user->roles[0] ) ) {
newrelic_set_user_attributes( $user->ID, '', $user->roles[0] );
} else {
newrelic_set_user_attributes( $user->ID, '', 'no-role' );
}
} else {
newrelic_set_user_attributes( 'not-logged-in', '', 'no-role' );
}
Expand Down

0 comments on commit 50f6767

Please sign in to comment.