fbpx
Awesome

Hide the ACF Admin Menu Item on Selected Sites

If you’re using ACF-JSON to manage your field groups there’s typically no need to see the ACF menu item called ‘Custom Fields’ on your staging or production sites.

It’s likely you’d need to keep the ACF ‘Custom Fields’ menu item visible for local development. You can use a variation of the snippet below to do exactly this. Just update the list of domains you wish to hide and you’ll be good to go!

<?php
add_filter( 'acf/settings/show_admin', function () {
// Get the current site url.
$site_url = get_bloginfo( 'url' );
// Define an array of protected site urls.
$protected_urls = array(
'https://www.example.com',
'http://staging.example.com'
);
// If the current site URL is in the array of protected URLs, return FALSE
// to hide the menu.
return ! in_array( $site_url, $protected_urls );
} );

This is a Hookturn plugin ad block

This is a Hookturn plugin ad block

Built by Hookturn

This site was created by Hookturn, the team behind ACF Theme Code Pro. If you are interested in contributing or have an extension to add, email us.

Sponsored by Pressidium

Awesome ACF is sponsored by the very awesome team at Pressidium. If you need reliable, secure and scalable Managed WordPress Hosting, check them out.

Stay up to date with all things ACF

TODO: Registration form here