bbp_add_forums_roles( WP_Roles $wp_roles = null )

Add the bbPress roles to the $wp_roles global.


Description Description

We do this to avoid adding these values to the database.

Note: bbPress is purposely assertive here, overwriting any keys & values that may already exist in the $wp_roles array.


Parameters Parameters

$wp_roles

(Optional) The array of WP_Role objects that was initialized

Default value: null


Top ↑

Return Return

(WP_Roles) The main $wp_roles global


Top ↑

Source Source

File: includes/core/capabilities.php

function bbp_add_forums_roles( $wp_roles = null ) {

	// Get the dynamic roles
	$bbp_roles = bbp_get_dynamic_roles();

	// Loop through dynamic roles and add them to the $wp_roles array
	foreach ( $bbp_roles as $role_id => $details ) {
		$wp_roles->roles[ $role_id ]        = $details;
		$wp_roles->role_objects[ $role_id ] = new WP_Role( $role_id, $details['capabilities'] );
		$wp_roles->role_names[ $role_id ]   = $details['name'];
	}

	// Return the modified $wp_roles array
	return $wp_roles;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.