Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hide the ACF admin menu dynamically based on site domain
<?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 );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment