Views Custom Query Filter – Check for custom Author cap.

Create a View with parametric search and a plotted map listing posts of a CPT.

All of those posts will have different authors.

All authors will either own a certain capability (managed by the groups plugin that stores these capabilities in the plugin’s own tables) or not.

Retrieve the capability of the author by using this function:

which returns 1 if the author has the capability and 0 if the author does not have the capability.

This wpv_filter_query_post_process now lists the posts of authors who own the capability – means where the above function would return 1.

add_filter( 'wpv_filter_query_post_process', 'prefix_modify_empty_query', 10, 3 );
function prefix_modify_empty_query( $query, $view_settings, $view_id )
{
 
    if ($view_id == 41)
    {
 
        // get some posts (author-profile cpt)
        $args = array(
            'posts_per_page'   => -1,
            'post_type'        => 'author-profile',
            'post_status'      => 'publish',
        );
        $posts_array = new WP_Query($args);
 
        //If there are some posts
        if (!empty($posts_array->posts))
        {
            //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->posts 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', $post_array->post_author));
                $can_make_donuts = $groups_user->can('pp_speaker');
 
                if ($can_make_donuts)
                    $valid_posts[] = $post_array;
            }
        }
 
        //If there are posts with this author / cap
        if (!empty($valid_posts))
        {
            //assign the valid posts array to the query
            $query->posts = $valid_posts;
        }
 
    }
 
 
    return $query;
}

Extending CRED allowed tags

add_filter( 'wp_kses_allowed_html', 'esw_author_cap_filter',1,1 );

function esw_author_cap_filter( $allowedposttags ) {

//Here put your conditions, depending your context

if ( !current_user_can( 'publish_posts' ) )
return $allowedposttags;

// Here add tags and attributes you want to allow

$allowedposttags['iframe']=array(

'align' => true,
'width' => true,
'height' => true,
'frameborder' => true,
'name' => true,
'src' => true,
'id' => true,
'class' => true,
'style' => true,
'scrolling' => true,
'marginwidth' => true,
'marginheight' => true,
);
return $allowedposttags;
}