Limit a query to a specific 'type'
-
I am using a plug in, which stores tickets as posts (Awesome Support Plugin)
in the plugin classes, there is a function to restrict the tickets loading in the admin panel, basically to show tickets to agent where the tickets are assigned to.
now I want to pimp this function a little bit to have super visors for this agents and show the tickets to them but not all of the tickets, just the tickets which are related to them.
basically I want to recreate the wordpress filters in the posts page for a parameter called ‘type’.
I found this ‘type’ param from the url address bar of the browser when I set the filter in the WP backend panel.here is the function:
/** * We prevent the agents from seeing * other agents tickets. This also * applies to admins if the option * is enabled. * * @param (object) $query The page's main query * @return (object) Updated query */ public function restrictTickets($query) { global $pagenow, $current_user, $user_ID; if( current_user_can( 'administrator' ) && wpas_get_option( 'admins_see_all', 'no' ) == 'yes' ) return; // so support admin can see all the tickets if( current_user_can('see_all_tickets') ) return; // so support managers can see all the tickets in their field if( current_user_can('see_related_tickets') && isset( $_GET['post_type'] ) && 'tickets' == $_GET['post_type']){ if( $query->query_vars['post_type'] == 'tickets' ) { // this is the field which I should set, and unfortunately does not work! --->>>> $query->query['type'] = 29; return $query; } } if( is_admin() && isset( $_GET['post_type'] ) && 'tickets' == $_GET['post_type'] ) { if( $query->query_vars['post_type'] == 'tickets' ) { $query->query_vars['meta_key'] = WPAS_PREFIX.'assignee'; $query->query_vars['meta_value'] = $current_user->data->ID; /* Fix wrong post count */ add_filter( "views_edit-tickets", array( $this, 'fixPostCount' ) ); } } return $query; }
can anyone help me, please?!
- The topic ‘Limit a query to a specific 'type'’ is closed to new replies.