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

Closed. This question is off-topic. It is not currently accepting answers.Questions that are too localized (such as synt

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745280622a4620259.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信