Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schutzsmith/5d0da6481190d1a2798470b1e22fad5c to your computer and use it in GitHub Desktop.
Save schutzsmith/5d0da6481190d1a2798470b1e22fad5c to your computer and use it in GitHub Desktop.
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