Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'wpv_filter_query_post_process', 'prefix_modify_empty_query', 10, 3 );
- function prefix_modify_empty_query( $query, $view_settings, $view_id )
- {
- if (!empty($query->posts))
- {
- $valid_posts = array();
- foreach ($query->posts as $post)
- {
- //check the author cap here
- $cap_is_good = new_pp_speaker_cap_yes($post);
- if ($cap_id_good)
- $valid_posts[] = $post;
- }
- if (!empty($valid_posts))
- {
- $query->posts = $valid_posts;
- $query->post_count = $count($valid_posts);
- }
- }
- return $query;
- }
- function new_pp_speaker_cap_yes($post)
- {
- require_once( ABSPATH . 'wp-includes/pluggable.php' );
- $groups_user = new Groups_User(get_the_author_meta('ID', $post->post_author));
- $author_can_speaker = $groups_user->can( 'pp_speaker' );
- if ( empty($author_can_speaker) ) {
- $author_can_speaker = 0;
- }
- return $author_can_speaker ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement