Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1418134
Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 5 years ago.
Improve this questionI was hoping to limit the access that my new team of contributors have through the dashboard; and stumbling this video on YouTube on how to possibly limit this; i thought i'd give it a shot.
- Here's a link for reference:
So i went ahead and added the code to my functions.php; and after saving to see the results i had been revoked access to my own editor as admin with full rights.
Here is the code i had added:
define( 'DISALLOW_FILE_EDIT', true);
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'jetpack' ); //Jetpack* // remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'options-general.php' ); //Settings remove_menu_page( 'wpcf7' ); //contact form
}
if(current_user_can('administrator')){
add_action( 'admin_menu','remove_menus' );
}
Is it possible to rollback or have the entire code removed without completely restarting my entire site again.
Thanks, Aaron
Closed. This question is off-topic. It is not currently accepting answers.Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 5 years ago.
Improve this questionI was hoping to limit the access that my new team of contributors have through the dashboard; and stumbling this video on YouTube on how to possibly limit this; i thought i'd give it a shot.
- Here's a link for reference: https://www.youtube/watch?v=9gUCVWjI6OA
So i went ahead and added the code to my functions.php; and after saving to see the results i had been revoked access to my own editor as admin with full rights.
Here is the code i had added:
define( 'DISALLOW_FILE_EDIT', true);
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'jetpack' ); //Jetpack* // remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'options-general.php' ); //Settings remove_menu_page( 'wpcf7' ); //contact form
}
if(current_user_can('administrator')){
add_action( 'admin_menu','remove_menus' );
}
Is it possible to rollback or have the entire code removed without completely restarting my entire site again.
Thanks, Aaron
Share Improve this question edited Jul 31, 2019 at 15:11 RiddleMeThis 3,8078 gold badges22 silver badges30 bronze badges asked Jul 31, 2019 at 14:55 AaronAaron 32 bronze badges2 Answers
Reset to default 0Issue #1
This line of code define( 'DISALLOW_FILE_EDIT', true);
does not go into functions.php. It should be removed from function.php and put in your config file, wp-config.php in the root of your WP install.
Here is more info on what DISALLOW_FILE_EDIT
does.
Issue #2
You are removing the menu items for admins.
if(current_user_can( 'administrator' )){
add_action( 'admin_menu','remove_menus' );
}
That is saying if the user is an admin remove your menus. Sounds like you want the opposite of that so you should be able to do something like this...
if(!current_user_can( 'administrator' )){
add_action( 'admin_menu','remove_menus' );
}
Removed images to keep links confidential - the issue has been solved
本文标签:
版权声明:本文标题:php - Used a code to revoke some dashboard menus for my contributors but for some reason it's revoked me access to the e 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745280622a2651404.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论