读书人

批改 页面编辑 的权限

发布时间: 2012-08-27 21:21:57 作者: rapoo

修改 页面编辑 的权限

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前端

热点推荐