Hide the ACF menu

Overview

When delivering a website to a client, it may be beneficial to hide the Advanced Custom Fields menu item. This will prevent your client from changing / deleting fields and will keep the website running smoothly.

Hide for all users

The ACF menu item can be hidden using the following code. Please note that '__return_false' is a WordPress function which simply returns false

functions.php

add_filter('acf/settings/show_admin', '__return_false');

Hide for specific users

The above code 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.

functions.php

add_filter('acf/settings/show_admin', 'my_acf_show_admin');

function my_acf_show_admin( $show ) {
    
    return current_user_can('manage_options');
    
}

 

Hi all. Server maintenance scheduled this Sunday 28th May. Learn more