Tell us what you are trying to do? Display all private posts created by all users to administrator and woo-commerce shop manager
Is there any documentation that you are following?
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
https://toolset.com/forums/topic/how-to-use-wpv_filter_query/
Is there a similar example that we can see?
not sure
What is the link to your site?
hidden link
Initially i thought to use "wpv_filter_query" however used the following code:
add_action( 'pre_get_posts', 'see_private_posts' );
function see_private_posts( $query ) {
// Make sure the query contains a post_type query_var,
// otherwise it's definitely not a request for Task(s):
if ( isset($query->query_vars['post_type']) ) {
// Check if the request is for the Task post type…
if ( $query->query_vars['post_type'] == 'client-portfolio' || ['post_type'] == 'personal-portfolio' ) {
// … and the current user is admin or store manager:
if ( current_user_can( 'shop_manager' ) || current_user_can( 'administrator') ) {
// If so, Editors and Administrators see all private tasks…
$query->set( 'post_status', 'private' );
} elseif ( current_user_can( 'subscriber' ) ) {
// … and Task Loggers see only their own tasks:
$query->set( 'post_status', 'private' );
$query->set( 'author', get_current_user_id() );
}
}
}
}
not sure if i missed anything or if i should use another API call.
please advise,
thanks,
David
My issue is resolved now. Thank you!