Hi All,
I want to hide a tab in a flexible content block with a true/false option in the site settings. So i’ve been looking at the prepare field section and try some code. But I can’t get it done. This is my code:
// Apply to fields named "example_field".
add_filter('acf/prepare_field/key=field_60647c32d82ce', 'hide_ani_tab');
function hide_ani_tab($field) {
if ( false == get_field( 'animation_option', 'option' ) ) {
// remove tab by field key
unset( $field[ '60647c32d82ce' ] );
}
return $field;
}
Can somebody help me out with this?
Thanks!
Not only would you need to hide the tab but you would also need to filter and hide all of the fields in that tab.
You do not want to unset the field, you need to return false
// Apply to fields named "example_field".
add_filter('acf/prepare_field/key=field_60647c32d82ce', 'hide_ani_tab');
function hide_ani_tab($field) {
if ( false == get_field( 'animation_option', 'option' ) ) {
// remove tab by field key
return false;
}
return $field;
}
but as I said, this would need to be done for the tab and all of the fields in the tab