diff --git a/classes/class-wp-nr-apm.php b/classes/class-wp-nr-apm.php index c8b3c54..4172639 100644 --- a/classes/class-wp-nr-apm.php +++ b/classes/class-wp-nr-apm.php @@ -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' ); }