Skip to main content
We are Brand SEO Beijing serving international business, your marketing partner, Contact us by mi@mgsh.com.cn

How to make website editors only see their own articles

The first method: (not recommended)
Just copy the code below into your theme's functions.php.
function wpjam_parse_query_useronly( $wp_query ) { if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) { if ( !current_user_can( 'add_user' ) ) { global $current_user ; $wp_query->set( 'author', $current_user->id ); } } } add_filter('parse_query', 'wpjam_parse_query_useronly' );
3f25f9bd99754e718550f951a7b56502 th e1584612620354-品牌-SEO-舆情-优化-米国生活
Note: If you copy the above code to function.php, after the admin user logs in, you can only see the articles published by the admin, but not all the articles.
The second method: (recommended)
This method can ensure that the admin user can see the articles of all users after logging in, because level_10 represents the admin user
function mypo_parse_query_useronly( $wp_query ) {
if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
if ( !current_user_can( 'level_10' ) ) {
global $current_user;
$wp_query->set( 'author', $current_user->id );
}
}
}
add_filter('parse_query', 'mypo_parse_query_useronly' );
The third type: (I didn't find it, I don't know if it works or not)
WP plugin: Restrict Author Posting
For more content, please click on Baidu and build a website for the American Business School.

Back to Top