Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/18/2014 01:15:40 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Improvements to Blogs & capabilities:

  • Introduce bp_blogs_get_allowed_roles() to act as a blog-role whitelist
  • Introduce bp_get_current_blog_roles() to avoid including an admin-only file theme-side
  • Use these functions to clean-up the add_user_to_blog process in several ways:

More accurately match the member-to-blog relationship specification
No-subscriber users remains functionality intact
Allow extending of existing user-to-blog behavior

See #5749, #5819.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-caps.php

    r7847 r8942  
    1010// Exit if accessed directly
    1111if ( !defined( 'ABSPATH' ) ) exit;
     12
     13/**
     14 * Return an array of roles from the currently loaded blog
     15 *
     16 * WordPress roles are dynamically flipped when calls to switch_to_blog() and
     17 * restore_current_blog() are made, so we use and trust WordPress core to have
     18 * loaded the correct results for us here. As enhancements are made to
     19 * WordPresss's RBAC, so should our capability functions here.
     20 *
     21 * @since BuddyPress (2.1.0)
     22 *
     23 * @return array
     24 */
     25function bp_get_current_blog_roles() {
     26    global $wp_roles;
     27
     28    // Sanity check on roles global variable
     29    $roles = isset( $wp_roles->roles )
     30        ? $wp_roles->roles
     31        : array();
     32
     33    // Apply WordPress core filter to editable roles
     34    $roles = apply_filters( 'editable_roles', $roles );
     35
     36    // Return the editable roles
     37    return apply_filters( 'bp_get_current_blog_roles', $roles, $wp_roles );
     38}
    1239
    1340/**
Note: See TracChangeset for help on using the changeset viewer.