Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Modify query approach approach
- * Based on Sarah Gooding's post
- * http://premium.wpmudev.org/blog/how-to-limit-the-wordpres-posts-screen-to-only-show-authors-their-own-posts/
- */
- function mypo_parse_query_useronly( $wp_query ) {
- if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
- if ( ! current_user_can( 'edit_others_sebamembers' ) ) {
- global $current_user;
- $wp_query->set( 'author', $current_user->ID );
- add_filter('views_edit-seba_members', 'fix_post_counts');
- }
- }
- }
- add_filter( 'pre_get_posts', 'mypo_parse_query_useronly' );
- /*********************************** OR **********************************************/
- /*
- * Add query arg approach
- * Based on Kailey Lampert's answer:
- * http://wordpress.stackexchange.com/a/37629/6477
- */
- function posts_for_current_author() {
- if ( ! current_user_can( 'edit_others_sebamembers' ) ) {
- global $user_ID;
- add_filter('views_edit-seba_members', 'fix_post_counts');
- if ( ! isset( $_GET['author'] ) ) {
- wp_redirect( add_query_arg( 'author', $user_ID ) );
- exit;
- }
- }
- }
- add_action( 'load-edit.php', 'posts_for_current_author' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement