_bbp_reinit_dynamic_roles( array $roles = array() )

This is necessary because in a few places (noted below) WordPress initializes a blog’s roles directly from the database option. When this happens, the $wp_roles global gets flushed, causing a user to magically lose any dynamically assigned roles or capabilities when $current_user in refreshed.

Description

Because dynamic multiple roles is a new concept in WordPress, we work around it here for now, knowing that improvements will come to WordPress core later.

Also note that if using the $wp_user_roles global non-database approach, Forums does not have an intercept point to add its dynamic roles.

See also

Parameters

$roles

(array) (Optional)

Default value: array()

Return

(array) Combined array of database roles and dynamic Forums roles

Source

File: bp-forums/core/capabilities.php

function _bbp_reinit_dynamic_roles( $roles = array() ) {
	foreach ( bbp_get_dynamic_roles() as $role_id => $details ) {
		$roles[$role_id] = $details;
	}
	return $roles;
}

Changelog

Changelog
Version Description
bbPress (r4363) 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.