Skip to content

Instantly share code, notes, and snippets.

@aj-adl
Created May 2, 2019 04:56
Show Gist options
  • Save aj-adl/fdb78e76022a78419a14e79ddcf3e314 to your computer and use it in GitHub Desktop.
Save aj-adl/fdb78e76022a78419a14e79ddcf3e314 to your computer and use it in GitHub Desktop.
Hide the ACF menu in the Wordpress admin.
<?php
function my_namespace_remove_acf_from_admin_menu(){
/* How you determing if it's production or not is up to you, we set a constant */
if ( ! defined( 'WP_ENV' ) || WP_ENV !== 'production ) return;
/* You can whitelist some users by id, or with a little more code, their username etc*/
$whitlisted_users = [];
if ( in_array( get_current_user_id(), $whitelist_users ) ) return ;
remove_menu_page('edit.php?post_type=acf-field-group');
}
add_action( 'admin_menu', 'my_namespace_remove_acf_from_admin_menu' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment