I want to show posts ( under a custom post type ) only posted by the current logged in user.I have used this code for reservation
and listings
Below here is the code
add_filter( 'parse_query', 'pre_order_posts_filter' );
function pre_order_posts_filter( $query ) {
global $post_type;
if(is_admin()){
$current_user = wp_get_current_user();
if ( 'reservation' == $post_type ) {
if ( in_array( 'shop_manager', $current_user->roles ) ) {
$query->query_vars['meta_key'] = 'author_id';
$query->query_vars['meta_value'] = $current_user->ID;
$query->query_vars['post_status'] = array('pending', 'publish');
}
}
elseif ( 'listings' == $post_type ) {
if ( in_array( 'shop_manager', $current_user->roles ) ) {
$query->query_vars['post_author'] = $current_user->ID;
}
}
}
}
Its working for reservation
but not for listings
.