bp_add_caps()

Add capabilities to WordPress user roles.

Description

This is called on plugin activation.

Source

File: bp-core/bp-core-caps.php

function bp_add_caps() {
	global $wp_roles;

	// Load roles if not set.
	if ( ! isset( $wp_roles ) ) {
		$wp_roles = new WP_Roles();
	}

	// Loop through available roles and add them.
	foreach( $wp_roles->role_objects as $role ) {
		foreach ( bp_get_caps_for_role( $role->name ) as $cap ) {
			$role->add_cap( $cap );
		}
	}

	/**
	 * Fires after the addition of capabilities to WordPress user roles.
	 *
	 * This is called on plugin activation.
	 *
	 * @since BuddyPress 1.6.0
	 */
	do_action( 'bp_add_caps' );
}

Changelog

Changelog
Version Description
BuddyPress 1.6.0 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.