/** * Add the bbPress roles to the $wp_roles global. * * We do this to avoid adding these values to the database. * * @since bbPress (r4290) * * @uses bbp_get_wp_roles() To load and get the $wp_roles global * @uses bbp_get_dynamic_roles() To get and add bbPress's roles to $wp_roles * @return WP_Roles The main $wp_roles global */ function bbp_add_forums_roles() { $wp_roles = bbp_get_wp_roles(); 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 $wp_roles; }
/** * Get the available roles minus bbPress's dynamic roles * * @since 2.4.0 bbPress (r5064) * * @uses bbp_get_wp_roles() To load and get the $wp_roles global * @return array */ function bbp_get_blog_roles() { // Get WordPress's roles (returns $wp_roles global) $wp_roles = bbp_get_wp_roles(); // Apply the WordPress 'editable_roles' filter to let plugins ride along. // // We use this internally via bbp_filter_blog_editable_roles() to remove // any custom bbPress roles that are added to the global. $the_roles = isset($wp_roles->roles) ? $wp_roles->roles : false; $all_roles = apply_filters('editable_roles', $the_roles); return apply_filters('bbp_get_blog_roles', $all_roles, $wp_roles); }