stream
stream copied to clipboard
Filter by User Role
Currently Stream only allows filtering records by User, not User Role.
The Exclude Rules have a dropdown which includes User Role. This should be used for filtering, too.

Yes, please! :)
Will this be added soon?
@nebbens We've got some other priorities at the moment. Would be happy to look at any pull requests though.
For anybody that does need this. Stream supports filtering by User Role, but doesn't have the dropdown yet. Here's my code:
<?php
namespace Peinemann\Stream\Filter;
class UserRole {
public function register_hooks() {
add_filter('wp_stream_list_table_filters',[ $this, 'add_user_role_filter' ] );
}
public function add_user_role_filter( $filters ){
$roles = get_editable_roles();
$items = [];
foreach( $roles as $key => $role ){
$items[ $key ] = [
'label' => $role['name'],
'disabled' => '',
];
}
if( !empty( $items ) ) {
$filters['user_role'] = array(
'title' => __( 'User role', 'peinemann' ),
'items' => $items,
);
}
return $filters;
}
}