How to filter / exclude posts by id in list of posts in WordPress Dashboard / Admin -


so, trying filter list of posts (mine custom post type) in wordpress dashboard id.

i checking area (custom widget) see if user can edit given post (not, intentionally dodging wordpress roles, etc), if cannot want filter/exclude post list.

i want take list:

see image: https://lh6.googleusercontent.com/-nqldupohuig/t84suxwqndi/aaaaaaaab1o/fzzvcksjawi/w678-h533-k/list_of_posts.png

...and filter out post id's function returns

okay, i've answered own question. here code on how did it.

function exclude_list_per_function( $query ) {      global $wpdb;      //gets post id's, know bit of hack     $querystr = "         select $wpdb->posts.id         $wpdb->posts     "; $post_ids = $wpdb->get_results($querystr, object);          //go through each post , pass function returns true if user_can, , false if user_can't         foreach($post_ids $post_obj){             if(!can_user_other_function_view_this_post(get_post($post_obj->id))){                 //if they_can't, add them array excluded                 $posts_not_in[]=$post_obj->id;             }         }          //set posts excluded list.         $query->set( 'post__not_in', $posts_not_in ); }  add_action( 'pre_get_posts', 'exclude_list_per_function'); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -