(r6965) * * @param string $default Optional. Default value 'edit' * @return string */ function bbp_get_edit_slug( $default = 'edit' ) { // Filter & return return apply_filters( 'bbp_get_edit_slug', get_option( '_bbp_edit_slug', $default ) ); } /** Legacy ********************************************************************/ /** * Checks if there is a previous BuddyPress Forum configuration * * @since 2.1.0 bbPress (r3790) * * @param string $default Optional. Default empty string * @return string The location of the bb-config.php file, if any */ function bbp_get_config_location( $default = '' ) { // Filter & return return apply_filters( 'bbp_get_config_location', get_option( 'bb-config-location', $default ) ); } e option. When this happens, the * $wp_roles global gets flushed, causing a user to magically lose any * dynamically assigned roles or capabilities when $current_user in refreshed. * * Because dynamic multiple roles is a new concept in WordPress, we work around * it here for now, knowing that improvements will come to WordPress core later. * * Also note that if using the $wp_user_roles global non-database approach, * bbPress does not have an intercept point to add its dynamic roles. * * @see bbp_switch_to_site() * @see bbp_restore_current_site() * @see WP_Roles::_init() * * @since 2.2.0 bbPress (r4363) * @deprecated 2.6.0 bbPress (r6105) * * @internal Used by bbPress to reinitialize dynamic roles on blog switch * * @param array $roles * @return array Combined array of database roles and dynamic bbPress roles */ function _bbp_reinit_dynamic_roles( $roles = array() ) { foreach ( bbp_get_dynamic_roles() as $role_id => $details ) { $roles[ $role_id ] = $details; } return $roles; } /** * Fetch a filtered list of forum roles that the current user is * allowed to have. * * Simple function who's main purpose is to allow filtering of the * list of forum roles so that plugins can remove inappropriate ones depending * on the situation or user making edits. * * Specifically because without filtering, anyone with the edit_users * capability can edit others to be administrators, even if they are * only editors or authors. This filter allows admins to delegate * user management. * * @since 2.2.0 bbPress (r4284) * @since 2.6.0 bbPress (r6117) Use bbpress()->roles * * @return array */ function bbp_get_dynamic_roles() { // Defaults $to_array = array(); $roles = bbpress()->roles; // Convert WP_Roles objects to arrays foreach ( $roles as $role_id => $wp_role ) { $to_array[ $role_id ] = (array) $wp_role; } // Filter & return return (array) apply_filters( 'bbp_get_dynamic_roles', $to_array, $roles ); } /** * Gets a translated role name from a role ID * * @since 2.3.0 bbPress (r4792) * @since 2.6.0 bbPress (r6117) Use bbp_translate_user_role() * * @param string $role_id * @return string Translated role name */ function bbp_get_dynamic_role_name( $role_id = '' ) { $roles = bbp_get_dynamic_roles(); $role = isset( $roles[ $role_id ] ) ? bbp_translate_user_role( $roles[ $role_id ]['name'] ) : ''; // Filter & return return apply_filters( 'bbp_get_dynamic_role_name', $role, $role_id, $roles ); } /** * Removes the bbPress roles from the editable roles array * * This used to use array_diff_assoc() but it randomly broke before 2.2 release. * Need to research what happened, and if there's a way to speed this up. * * @since 2.2.0 bbPress (r4303) * * @param array $all_roles All registered roles * @return array */ function bbp_filter_blog_editable_roles( $all_roles = array() ) { // Loop through bbPress roles foreach ( array_keys( bbp_get_dynamic_roles() ) as $bbp_role ) { // Loop through WordPress roles foreach ( array_keys( $all_roles ) as $wp_role ) { // If keys match, unset if ( $wp_role === $bbp_role ) { unset( $all_roles[ $wp_role ] ); } } } return $all_roles; } /** * The keymaster role for bbPress users * * @since 2.2.0 bbPress (r4284) * * @return string */ function bbp_get_keymaster_role() { // Filter & return return apply_filters( 'bbp_get_keymaster_role', 'bbp_keymaster' ); } /** * The moderator role for bbPress users * * @since 2.0.0 bbPress (r3410) * * @return string */ function bbp_get_moderator_role() { // Filter & return return apply_filters( 'bbp_get_moderator_role', 'bbp_moderator' ); } /** * The participant role for registered user that can participate in forums * * @since 2.0.0 bbPress (r3410) * * @return string */ function bbp_get_participant_role() { // Filter & return return apply_filters( 'bbp_get_participant_role', 'bbp_participant' ); } /** * The spectator role is for registered users without any capabilities * * @since 2.1.0 bbPress (r3860) * * @return string */ function bbp_get_spectator_role() { // Filter & return return apply_filters( 'bbp_get_spectator_role', 'bbp_spectator' ); } /** * The blocked role is for registered users that cannot spectate or participate * * @since 2.2.0 bbPress (r4284) * * @return string */ function bbp_get_blocked_role() { // Filter & return return apply_filters( 'bbp_get_blocked_role', 'bbp_blocked' ); } /** * Adds bbPress-specific user roles. * * @since 2.0.0 bbPress (r2741) * * @deprecated 2.2.0 bbPress (r4164) */ function bbp_add_roles() { _doing_it_wrong( 'bbp_add_roles', esc_html__( 'Editable forum roles no longer exist.', 'bbpress' ), '2.2' ); } /** * Removes bbPress-specific user roles from the `wp_user_roles` array. * * This is currently only used when updating, uninstalling, or resetting bbPress. * * @see bbp_admin_reset_handler() * @see bbp_do_uninstall() * @see bbp_version_updater() * * @since 2.0.0 bbPress (r2741) */ function bbp_remove_roles() { // Remove the bbPress roles foreach ( array_keys( bbp_get_dynamic_roles() ) as $bbp_role ) { remove_role( $bbp_role ); } // Some early adopters may have a deprecated visitor role. It was later // replaced by the Spectator role. remove_role( 'bbp_visitor' ); }