最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Used a code to revoke some dashboard menus for my contributors but for some reason it's revoked me access to the e

programmeradmin1浏览0评论
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 question

I 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 question

I 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 badges
Add a comment  | 

2 Answers 2

Reset to default 0

Issue #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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论