0

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.

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 as off-topic by fuxia Jul 31 at 16:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

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' ); 
}
  • I cannot access the functions.php nor can i find it on my hosted database. I do apologise im not really good at this. **Okay i've located the functions.php on my 1and1 hosted database but i cannot find the code to have replaced with your correction – Aaron Jul 31 at 15:02
  • Sounds like you will have to access your files via FTP if you locked your self out of the admin. If you don't know how to do that you might just want to contact your host and have them help. – RiddleMeThis Jul 31 at 15:08
  • I do have access to the FTP i just don't know what to do on it. I'm sorry if i sound like an idiot – Aaron Jul 31 at 15:11
  • Edit your functions.php file and remove define( 'DISALLOW_FILE_EDIT', true); Also add the ! in your IF statement. Edit your wp-config.php and add define( 'DISALLOW_FILE_EDIT', true); if you need it. – RiddleMeThis Jul 31 at 15:15
  • 1
    Whenever somebody says "your functions.php file" in reference to WordPress, they mean the wp-content/themes/{your theme}/functions.php file. Never edit wp-includes/functions.php. – Jacob Peattie Jul 31 at 15:46
0

Removed images to keep links confidential - the issue has been solved

Not the answer you're looking for? Browse other questions tagged or ask your own question.