Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. function posts_for_current_author($query) {
  2. global $pagenow;
  3. $tempuser = wp_get_current_user();
  4. if( 'edit.php' != $pagenow || !$query->is_admin )
  5. return $query;
  6.  
  7. if( in_array( 'client-event', (array) $tempuser->roles ) ) {
  8. add_action( 'views_edit-post', 'child_remove_some_post_views' );
  9. global $user_ID;
  10. $query->set('author', $user_ID );
  11. }
  12. return $query;
  13. }
  14. function child_remove_some_post_views( $views ) {
  15. unset($views['all']);
  16. unset($views['publish']);
  17. unset($views['trash']);
  18. unset($views['draft']);
  19. unset($views['pending']);
  20. return $views;
  21. }
  22. add_filter('pre_get_posts', 'posts_for_current_author');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement