一個網(wǎng)站后臺都有權(quán)限限制管理員只能看到自己的文章,但wordpress則不能,下面我來介紹WordPress讓作者只能查看自己文章方法.
只要在主題 functions.php 文件中簡單的加入下面代碼即可解決,代碼如下:
- <?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 );
- }//開源軟件:Vevb.com
- }
- }
- add_filter('parse_query', 'wpjam_parse_query_useronly' );
- ?>
新聞熱點(diǎn)
疑難解答
圖片精選