SHARE
TWEET

Untitled

a guest Jun 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top