bbp_get_dynamic_roles()

Fetch a filtered list of forum roles that the current user is allowed to have.

Description

Simple function who’s main purpose is to allow filtering of the list of forum roles so that plugins can remove inappropriate ones depending on the situation or user making edits.

Specifically because without filtering, anyone with the edit_users capability can edit others to be administrators, even if they are only editors or authors. This filter allows admins to delegate user management.

Return

(array)

Source

File: bp-forums/core/capabilities.php

function bbp_get_dynamic_roles() {
	return (array) apply_filters( 'bbp_get_dynamic_roles', array(

		// Keymaster
		bbp_get_keymaster_role() => array(
			'name'         => 'Keymaster',
			'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() )
		),

		// Moderator
		bbp_get_moderator_role() => array(
			'name'         => 'Moderator',
			'capabilities' => bbp_get_caps_for_role( bbp_get_moderator_role() )
		),

		// Participant
		bbp_get_participant_role() => array(
			'name'         => 'Participant',
			'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() )
		),

		// Spectator
		bbp_get_spectator_role() => array(
			'name'         => 'Spectator',
			'capabilities' => bbp_get_caps_for_role( bbp_get_spectator_role() )
		),

		// Blocked
		bbp_get_blocked_role() => array(
			'name'         => 'Blocked',
			'capabilities' => bbp_get_caps_for_role( bbp_get_blocked_role() )
		)
	) );
}

Changelog

Changelog
Version Description
bbPress (r4284) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.