在WordPress后台的文章列表只显示该作者自己的文章

2019年12月17日15:22:28 发表评论 热度472 ℃

对于WordPress多作者博客,如何让每个作者在后台只能浏览自己的文章?只需要将下面的代码添加到你主题的 functions.php 即可:

  1. function mypo_parse_query_useronly( $wp_query ) {
  2.     if ( strpos$_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
  3.         if ( !current_user_can( 'level_10' ) ) {
  4.             global $current_user;
  5.             $wp_query->set( 'author', $current_user->id );
  6.         }
  7.     }
  8. }
  9. add_filter('parse_query', 'mypo_parse_query_useronly' );

操作十分的简单,这样作者进入WP后台就只能看见自己的文章内容了!

瓜皮猪

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: