Hide ACF Fields on Production Website
Why hide acf fields on production
- fields wont get overwritten when deploying from local or staging
- stop clients from deleting acf fields in production
How to hide
- add to
functions.php
- update protected urls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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://staging.cloud',
'https://live.com.au',
);
// 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 );
}
);
more info
This post is licensed under CC BY 4.0 by the author.