论坛首页 Web前端技术论坛

修改 页面编辑 的权限

浏览 2399 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2011-12-29  

WORDPRESS

有时候在页面编辑的时候 需要对后台进行一些自己的设置 防止客户或者某些人进行不规则举动来编辑页面

造成网站的破坏,

此时我们需要对某些页面进行 特定的处理 可以设置某些模板的页面的编辑功能不可用

这样我们需要在functions.php加入以下代码

改掉下面的_wp_page_template 为你的自己定义的模板
如此,只要引用此模板的页面都是不可见的了。
 add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
    $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
    if( !isset( $post_id ) ) return;
    $template_file = get_post_meta($post_id, '_wp_page_template', true);
    if($template_file == 'submit.php'){ // edit the template name
        remove_post_type_support('page', 'editor');
    }
}
 
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics