May I know it is possible to get view count for each user role? I would like to know the total count post views for different user role instead of only exclude specific user role.
There’s no direct way to do it but this can be achieved using two queries.
1. Get the user ids of a specific role by get_users() function and ‘role__in’ parameter https://codex.wordpress.org/Function_Reference/get_users
2. Then use the user ids you got to run a WP Query https://codex.wordpress.org/Class_Reference/WP_Query – here set the ‘author__in’ parameter with the user ids (to get posts of specific user roles) and set ‘orderby’ parameter to ‘post_views’ (to get post views data along with other post data).
3. In result PVC will extend the WP Query data with ‘total_views’ property giving you a sum of all the views of the posts found in the WP Query call.
Author
Posts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
How to Get Support
After you register and login to the site, you may post all plugin support questions in the Support Forum.
If you need to provide private info, please create a ticket and then reply to it using Set as private reply option.
Sign Up
Support is only provided to registered users.
Please login or sign up for a free account.Sign Up Now