Beda please ????
I have a view with a custom post-relationship filter that displays all post-type "BOOKINGS"
[wpv-control-post-relationship ancestors="organizer>event-plan>market>date" url_param="par"]
//form-fields
[/wpv-control-post-relationship]
The problem is that the filter shows ALL post-type "organizer, event-plan, market, date" available in the db.
I want to limit the filter fields to show only posts created by the logged in user.
I am unable to use the standard "post author filter" because post-type "bookings" can have any author.
The parent post-types I am filtering on, are all created by current user.
I am trying to build a filter but I dont know how to control the list of "ancestors":
The first ancestor is post-type "organizer".
My thought is to get all organizers created by current user and in that way limiting the first ancestor which in turn minimizes the following.
//Return only posts related to post-type:organizer where author=current user:
function prefix_check_org_author( $query_args, $view_id )
{
if ($view_id == 19015) {
global $current_user;
$organizer_args = array(
'post_type' => 'organizer',
'posts_per_page'=>-1,
'author' => $current_user->ID,
);
$user_organizers = new WP_Query( $organizer_args );
if ( $user_organizers->have_posts() ) {
while ( $user_organizers->have_posts() ) {
$user_organizers->the_post();
$post_id_array[] = get_the_ID();
}
}
$user_organizers->reset_postdata();
if ( !is_admin() ) {
$query_args['post_relationship'] = in_array( how to limit ancestor organizer here?, $post_id_array );
}
}
return $query_args;
}
add_filter( 'wpv_filter_query', 'prefix_check_org_author', 99, 2 );
Dear Tina,
There isn't such a built-in feature within Views shortcodes [wpv-control-post-relationship] and [wpv-control-item], see our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-control-post-relationship
And
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-control-item
There isn't such an option to "limit the filter fields to show only posts created by the logged in user".
And shortcode [wpv-control-item] is using it's own sql query to get the parent posts from database, so your custom PHP codes won't be able to work, if you agree, we can take it as a feature request, our developers will evaluate it.
Yes I would very much like this. Please post a feature request.
As your request, I have forwarded it to our supporter Beda, he manages the feature request of Views plugin, but there isn't any ETA for implementing it.
As your request, I have forwarded it to our supporter Beda, he manages the feature request of Views plugin, but there isn't any ETA for implementing it.