Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('wpv_filter_query', 'exclude_terms_func', 10, 3);
- function exclude_terms_func($query, $setting, $views_ID) {
- // get some posts (author-profile cpt)
- $args = array(
- 'posts_per_page' => -1,
- 'post_type' => 'author-profile',
- 'post_status' => 'publish',
- );
- $posts_array = get_posts( $args );
- //If there are some posts
- if ($posts_array){
- //build a array for valid (to return) posts
- $valid_posts = array();
- //we need to check if the posts author has the correct cap
- foreach ($posts_array as $post_array){
- //this custom code checks wehter the author (user) is / has capability 'pp_speaker'
- require_once( ABSPATH . 'wp-includes/pluggable.php' );
- $groups_user = new Groups_User( get_the_author_meta( 'ID' ) );
- $can_make_donuts = $groups_user->can( 'pp_speaker' );
- }
- }
- //If there are posts with this author / cap
- if ($can_make_donuts){
- //assign the valid posts array to the query
- $query = $valid_posts;
- return $query;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement