- 论坛徽章:
- 0
|
修改 页面编辑 的权限
有时候在页面编辑的时候 需要对后台进行一些自己的设置 防止客户或者某些人进行不规则举动来编辑页面
造成网站的破坏,
此时我们需要对某些页面进行 特定的处理 可以设置某些模板的页面的编辑功能不可用
这样我们需要在functions.php加入以下代码
Java代码- 1.改掉下面的_wp_page_template 为你的自己定义的模板
- 2.如此,只要引用此模板的页面都是不可见的了。
- 3. add_action( 'admin_init', 'hide_editor' );
- 4.function hide_editor() {
- 5. $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
- 6. if( !isset( $post_id ) ) return;
- 7. $template_file = get_post_meta($post_id, '_wp_page_template', true);
- 8. if($template_file == 'submit.php'){ // edit the template name
- 9. remove_post_type_support('page', 'editor');
- 10. }
- 11.}
复制代码 |
|