wordpress - 如何在 WP-admin UI 中隐藏高级自定义字段(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' );
?>
可以在此处找到该过滤器的文档:https ://www.advancedcustomfields.com/resources/acf-prepare_field/
推荐阅读
- php - 如何在 laravel 中为 spatie 包(ACL 管理)中的其他角色分配用户列表权限?
- python - Python定义funct()“未定义”
- cmake - 如何解决“找不到所需的组件‘libdlib’”错误?
- php - 如何在 Google Cloud App Engine 上运行 PHP 服务
- python - Pandas 根据条件将一列映射到另一列
- c# - 理解基本链表
- bash - 使用 Bash 计算程序的平均执行时间
- dart - 如何在 Flutter 中解码 JWT?
- algorithm - 使用距离矩阵查找带有航点的最短路线
- azure - 如何将 blob 容器中存在的一个大 zip 文件(100gb+)解压缩到另一个 blob 容器,我得到 System.OutOfMemoryException