替换 BuddyPress 默认角色用户名的方法,比较实在的自定义,要添加到 模板函数 (functions.php) 文件里面。


// 替换 BuddyPress 默认角色用户名
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://buddypress.org/forums/topic/addchange-user-roles/

收录于薇晓朵技术论坛,原帖地址:https://bbs.weixiaoduo.com/topic/17169