Aar*_*ron 3 wordpress wordpress-theming custom-wordpress-pages wordpress-thesis-theme
检查下面的屏幕截图;我想做的就是在 WordPress 后端隐藏自定义用户的某些 ACF 字段。
从 ACF 5.0.0 开始,有一种更简单的方法可以做到这一点,而无需输出 CSS。如果您使用acf/prepare_field钩子并返回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' );
?>
Run Code Online (Sandbox Code Playgroud)
该过滤器的文档可以在这里找到: https: //www.advancedcustomfields.com/resources/acf-prepare_field/
| 归档时间: |
|
| 查看次数: |
7819 次 |
| 最近记录: |