Skip to content
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

Fix non-zero role array logging #824

Merged
merged 4 commits into from
Mar 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions classes/class-log.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,18 @@ function( &$v ) {
// Get the current time in milliseconds
$iso_8601_extended_date = wp_stream_get_iso_8601_extended_date();

if ( ! empty( $user->roles ) ) {
$roles = array_values( $user->roles );
$role = $roles[0];
} else {
$role = '';
}
$recordarr = array(
'object_id' => (int) $object_id,
'site_id' => (int) is_multisite() ? get_current_site()->id : 1,
'blog_id' => (int) apply_filters( 'wp_stream_blog_id_logged', get_current_blog_id() ),
'user_id' => (int) $user_id,
'user_role' => (string) ! empty( $user->roles ) ? $user->roles[0] : '',
'user_role' => (string) $role,
'created' => (string) $iso_8601_extended_date,
'summary' => (string) vsprintf( $message, $args ),
'connector' => (string) $connector,
Expand Down Expand Up @@ -152,14 +158,18 @@ public function is_record_excluded( $connector, $context, $action, $user = null,
$ip = wp_stream_filter_var( $ip, FILTER_VALIDATE_IP );
}

$user_role = isset( $user->roles[0] ) ? $user->roles[0] : null;

if ( ! empty( $user->roles ) ) {
$roles = array_values( $user->roles );
$role = $roles[0];
} else {
$role = '';
}
$record = array(
'connector' => $connector,
'context' => $context,
'action' => $action,
'author' => $user->ID,
'role' => $user_role,
'role' => $role,
'ip_address' => $ip,
);

Expand Down