內容簡介
警告:自 4.0.0 版本起支援子欄位已被移除
這是針對 Advanced Custom Fields (ACF) 版本 5 的附加外掛程式。
若未安裝 ACF5,此外掛程式將不提供任何功能。
此外掛程式會在所有欄位類型中新增一個欄位設定,以便可選擇可編輯該欄位的使用者權限角色。
只有選定該欄位的角色才能編輯該欄位。
Github 存儲庫
此外掛程式也可在 GitHub 上取得:
https://github.com/Hube2/acf-user-role-field-setting
排除的欄位類型
大多數情況下,對於一個分頁欄位而言沒有意義,除非該分頁中的所有欄位都被設置為相同,換句話說,移除分頁應該也會移除該分頁中的所有欄位。目前無法實現此功能。
我不確定 Clone 欄位,我對它並不熟悉。您可以自行測試。
我還刪除了對 Repeater、Group 和 Flexible Content 欄位的支援,因為如果它們在 ACF 介面中不可編輯,我無法保留這些欄位的值。請注意,我不知道在這些欄位上啟用使用者角色設置的影響。
設有一個篩選器,以便調整要排除的欄位類型。以下是一個範例:
<?php
add_filter('acf/user_role_setting/exclude_field_types', 'user_role_setting_excluded_field_types');
function user_role_setting_excluded_field_types($exclude) {
/*
$exclude 包含一個要排除添加使用者角色設置的欄位類型的陣列
預設值:
$exclude = array('tab' => 'tab', 'clone' => 'clone');
*/
// 從排除列表移除分頁欄位
if (isset($exclude['tab'])) {
unset($exclude['tab']);
}
// 添加訊息欄位到排除列表
$exclude['message'] = 'message';
return $exclude;
}
?>
外掛標籤
開發者團隊
📦 歷史版本下載
原文外掛簡介
Warning: Support for Sub Fields Removed as of Version 4.0.0
This is an add on plugin for Advanced Custom Fields (ACF) Version 5.
This plugin will not provide any functionality if ACF5 is not installed.
This plugin adds a field setting to all field types so that user roles allowed to edit the field can
be selected. Only those roles selected for the field will be able to edit the field.
Github Repository
This plugin is also on GitHub
https://github.com/Hube2/acf-user-role-field-setting
Excluded Field Types
Most of the time it would not make sense for a tab field, unless all of the fields in the tab were set the same, in other words, removing a tab should remove all the fields in that tab. That’s not something that I can do at this point.
I’m not sure about the clone field, I haven’t worked with it much. You can test it out if you want.
I have also removed support for repeater, group and flexible content fields because I cannot preserver the values of these fields if they are not editable in the ACF interface. Please note that I do not know what the effect of allowing user role settings on these fields will be.
There is a filter so that you can adjust the types of fields that are excluded. Here is an example
'tab', 'clone' => 'clone');
*/
// remove tab field from exclude
if (isset($exclude['tab'])) {
unset($exclude['tab']);
}
// add message field to exclude
$exclude['message'] = 'message';
return $exclude;
}
?>
