Skip to content

Instantly share code, notes, and snippets.

@barbwiredmedia
Created July 15, 2014 20:42
Show Gist options
  • Save barbwiredmedia/04a6127510be4b68cefc to your computer and use it in GitHub Desktop.
Save barbwiredmedia/04a6127510be4b68cefc to your computer and use it in GitHub Desktop.
Hide ACF menu item from the admin menu. wordpress functions.php
/**
* Hide ACF menu item from the admin menu
*/
function remove_acf_menu()
{
// provide a list of usernames who can edit custom field definitions here
$admins = array(
'levy-access',
'fakename'
);
// get the current user
$current_user = wp_get_current_user();
// match and remove if needed
if( !in_array( $current_user->user_login, $admins ) )
{
remove_menu_page('edit.php?post_type=acf'); //ACF
remove_menu_page('edit.php'); //Posts
remove_menu_page('tools.php'); //Tools
}
}
add_action( 'admin_menu', 'remove_acf_menu' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment