最佳答案
从 ACF 5.0.0 开始,有一种更简单的方法可以做到这一点,而无需输出 CSS。如果您使用 acf/prepare_field
Hook 并返回 false
该字段将不会呈现。
<?php
function so37111468_hide_field( $field ) {
// hide the field if the current user is not able to save options within the admin
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
return $field;
}
add_filter( 'acf/prepare_field/key=MYFIELDKEY', 'so37111468_hide_field' );
?>
可以在此处找到该过滤器的文档:https://www.advancedcustomfields.com/resources/acf-prepare_field/
关于wordpress - 如何在 WP-admin UI 中隐藏高级自定义字段(ACF)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50011574/