bbp_add_forums_roles( WP_Roles $wp_roles = null )

Add the Forums roles to the $wp_roles global.

Description

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

Parameters

$wp_roles

(WP_Roles) (Optional) The main WordPress roles global

Default value: null

Return

(WP_Roles) The main $wp_roles global

Source

File: bp-forums/core/capabilities.php

function bbp_add_forums_roles( $wp_roles = null ) {

	// Attempt to get global roles if not passed in & not mid-initialization
	if ( ( null === $wp_roles ) && ! doing_action( 'wp_roles_init' ) ) {
		$wp_roles = bbp_get_wp_roles();
	}

	// Loop through dynamic roles and add them to the $wp_roles array
	foreach ( bbp_get_dynamic_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;
}

Changelog

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