如何替換 bbPress 默認角色用戶名的方法,自定義顯示名稱

替換 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

文章沒看懂?代碼不會用?需要幫助您可以去論壇提問自助服務台

作者風間

在哪裡跌倒,就在哪裡趴着。