Overview
When delivering a website to a client, it may be beneficial to hide the “ACF” menu item. This prevents your client from changing or deleting fields and keeps the site running smoothly.
This doc details three methods for hiding the ACF menu:
- Hiding the menu for all users on every site.
- Hiding the menu for specific users on every site.
- Hiding the menu on a live site while retaining functionality on the staging site.
This last option is likely the most common use case, as it allows you to continue editing fields when needed while ensuring clients can’t make any unauthorized changes.
Hide for All Users
The ACF menu item can be hidden for all users by adding the following code to the functions.php
file of the active theme. However, we recommend putting the code in an mu-plugin instead, ensuring it isn’t lost when switching themes. Please note that __return_false
is a WordPress function which simply returns false.
add_filter('acf/settings/show_admin', '__return_false');
Hide for Specific Users
The code above can be enhanced to only return false for specific users. The following code uses the WordPress function current_user_can()
to return true or false depending on the current user’s capability. Please note that manage_options
is a capability that only admins (and super admins) have by default.
add_filter('acf/settings/show_admin', 'my_acf_show_admin');
function my_acf_show_admin( $show ) {
return current_user_can('manage_options');
}
Hide on Live Site Only
Adding the code below to your functions.php
file hides the ACF menu on a live site, while retaining it on a staging or local development site.
if ( wp_get_environment_type() === 'production' ) {
// Only allow fields to be edited on development
add_filter( 'acf/settings/show_admin', '__return_false' );
}
Supercharge Your Website With Premium Features Using ACF PRO
Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.