Skip to content

Instantly share code, notes, and snippets.

@westcoastdigital
Created January 12, 2018 01:04
Show Gist options
  • Select an option

  • Save westcoastdigital/3e6033b28f3ab17fbbd174edcf37064f to your computer and use it in GitHub Desktop.

Select an option

Save westcoastdigital/3e6033b28f3ab17fbbd174edcf37064f to your computer and use it in GitHub Desktop.
Hide sections in admin based on user
function wcd_hide_admin_sections() {
$user = wp_get_current_user();
$access = 'admin'; // this is your username that gets access
if($user && isset($user->user_login) && $access != $user->user_login) { ?>
<style>
li#toplevel_page_edit-post_type-acf-field-group,
li#menu-appearance,
li#menu-plugins,
li#menu-users,
li#menu-settings,
li#menu-tools { display: none; }
</style>
<?php }
}
add_action( 'admin_head', 'wcd_hide_admin_sections' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment