bp_get_current_blog_roles()

Return an array of roles from the currently loaded blog.

Description

WordPress roles are dynamically flipped when calls to switch_to_blog() and restore_current_blog() are made, so we use and trust WordPress core to have loaded the correct results for us here. As enhancements are made to WordPress’s RBAC, so should our capability functions here.

Return

(object)

Source

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

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function bp_get_current_blog_roles() {
    global $wp_roles;
 
    // Sanity check on roles global variable.
    $roles = isset( $wp_roles->roles )
        ? $wp_roles->roles
        : array();
 
    /**
     * Filters the list of editable roles.
     *
     * @since BuddyPress 2.1.0
     *
     * @param array $roles List of roles.
     */
    $roles = apply_filters( 'editable_roles', $roles );
 
    /**
     * Filters the array of roles from the currently loaded blog.
     *
     * @since BuddyPress 2.1.0
     *
     * @param array    $roles    Available roles.
     * @param WP_Roles $wp_roles Object of WordPress roles.
     */
    return apply_filters( 'bp_get_current_blog_roles', $roles, $wp_roles );
}

Changelog

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