替換 bbPress 默認角色用戶名的方法,比較實在的自定義,要添加到 模板函數 (functions.php) 文件裡面。
// 替換 bbPress 默認角色用戶名
add_filter( 'bbp_get_dynamic_roles', 'ntwb_bbpress_custom_role_names' );
function ntwb_bbpress_custom_role_names() {
return array(
// Keymaster
bbp_get_keymaster_role() => array(
'name' => ' 管理員',
'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() )
),
// Moderator
bbp_get_moderator_role() => array(
'name' => ' 版主',
'capabilities' => bbp_get_caps_for_role( bbp_get_moderator_role() )
),
// Participant
bbp_get_participant_role() => array(
'name' => ' 社區成員',
'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() )
),
// Spectator
bbp_get_spectator_role() => array(
'name' => ' 觀眾',
'capabilities' => bbp_get_caps_for_role( bbp_get_spectator_role() )
),
// Blocked
bbp_get_blocked_role() => array(
'name' => ' 禁閉用戶',
'capabilities' => bbp_get_caps_for_role( bbp_get_blocked_role() )
)
);
}
在官方社區搜索到的, https://bbpress.org/forums/topic/addchange-user-roles/
收錄於薇曉朵技術論壇,原帖地址:https://bbs.weixiaoduo.com/topic/17169