倡萌在《禁止安装、升级或编辑WordPress主题和插件》提到了禁止在线编辑WordPress主题和插件的方法,如果我们仅仅是想限制某个用户不能使用在线编辑主题的功能,那可以将下面的代码添加到主题的 functions.php 文件中即可:
function wpdax_remove_editor_menu() {
remove_action('admin_menu', '_add_themes_utility_last', 101);
}
global $remove_submenu_page, $current_user;
get_currentuserinfo();
if($current_user->user_login == 'admin') { //请修改这里的 admin 为要限制的用户名称
add_action('admin_menu', 'wpdax_remove_editor_menu', 1);
} |
function wpdax_remove_editor_menu() {
remove_action('admin_menu', '_add_themes_utility_last', 101);
}
global $remove_submenu_page, $current_user;
get_currentuserinfo();
if($current_user->user_login == 'admin') { //请修改这里的 admin 为要限制的用户名称
add_action('admin_menu', 'wpdax_remove_editor_menu', 1);
}
这样,如果是 admin 用户登录后,就不会显示主题编辑菜单。请自行修改第7行中的用户名称。
提示:默认情况下,只有管理员级别的用户才能编辑主题文件;也就是说,如果你的网站有多个管理员账户,你可以使用这个方法限制某些管理员的主题编辑权限。
来源:
https://www.wpdaxue.com/prevent-a-user-to-edit-the-theme-file-online.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_33252.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57