Skip to content

Instantly share code, notes, and snippets.

@GregWallace
Last active August 29, 2015 13:58
Show Gist options
  • Select an option

  • Save GregWallace/10119539 to your computer and use it in GitHub Desktop.

Select an option

Save GregWallace/10119539 to your computer and use it in GitHub Desktop.
Hide ACF menu from admin
<?php
/**
* Hide ACF menu item from the admin menu
*** Reference url: http://www.advancedcustomfields.com/resources/how-to/how-to-hide-acf-menu-from-clients/
*/
function remove_acf_menu()
{
// provide a list of usernames who can edit custom field definitions here
$admins = array(
'admin',
'johndoe'
);
// 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');
}
}
add_action( 'admin_menu', 'remove_acf_menu', 999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment