首页 > CMS建站 > Wordpress > 正文

WordPress让作者只能查看自己文章方法

2020-06-10 12:58:19
字体:
来源:转载
供稿:网友

一个网站后台都有权限限制管理员只能看到自己的文章,但wordpress则不能,下面我来介绍WordPress让作者只能查看自己文章方法.

只要在主题 functions.php 文件中简单的加入下面代码即可解决,代码如下:

  1. <?php 
  2. function wpjam_parse_query_useronly( $wp_query ) { 
  3.     if ( strpos$_SERVER'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) { 
  4.         if ( !current_user_can( 'add_user' ) ) { 
  5.             global $current_user
  6.             $wp_query->set( 'author'$current_user->id ); 
  7.         }//开源软件:Cuoxin.com 
  8.     } 
  9. add_filter('parse_query''wpjam_parse_query_useronly' ); 
  10. ?>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选