Skip to:
Content

BuddyPress.org

Changeset 14194


Ignore:
Timestamp:
01/02/2026 07:02:18 PM (11 days ago)
Author:
espellcaste
Message:

Remove legacy deprecated functions related to BuddyPress user roles.

Most of those functions have been deprecated since version 1.6. And they have not been used in the codebase for a long time.

Here, we are properly removing them from the codebase.

Closes https://github.com/buddypress/buddypress/pull/436/
Fixes #9320

File:
1 edited

Legend:

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

    r14080 r14194  
    339339 * @since 2.7.0
    340340 *
    341  * @param int       $user_id
     341 * @param int       $user_id    User ID.
    342342 * @param string    $capability Capability or role name.
    343343 * @param array|int $args {
     
    358358    }
    359359
    360     $switched = is_multisite() ? switch_to_blog( $site_id ) : false;
     360    $switched = is_multisite() && switch_to_blog( $site_id );
    361361    $retval   = call_user_func_array( 'user_can', array( $user_id, $capability, $args ) );
    362362
     
    420420    }
    421421}
    422 add_action( 'wp_roles_init', '_bp_roles_init', 10, 1 );
    423 
    424 /** Deprecated ****************************************************************/
    425 
    426 /**
    427  * Temporary implementation of 'bp_moderate' cap.
    428  *
    429  * In BuddyPress 1.6, the 'bp_moderate' cap was introduced. In order to
    430  * enforce that bp_current_user_can( 'bp_moderate' ) always returns true for
    431  * Administrators, we must manually add the 'bp_moderate' cap to the list of
    432  * user caps for Admins.
    433  *
    434  * Note that this level of enforcement is only necessary in the case of
    435  * non-Multisite. This is because WordPress automatically assigns every
    436  * capability - and thus 'bp_moderate' - to Super Admins on a Multisite
    437  * installation. See {@link WP_User::has_cap()}.
    438  *
    439  * This implementation of 'bp_moderate' is temporary, until BuddyPress properly
    440  * matches caps to roles and stores them in the database.
    441  *
    442  * Plugin authors: Please do not use this function; thank you. :)
    443  *
    444  * @since 1.6.0
    445  * @deprecated 7.0.0
    446  *
    447  * @access private
    448  *
    449  * @see WP_User::has_cap()
    450  *
    451  * @param array  $caps    The caps that WP associates with the given role.
    452  * @param string $cap     The caps being tested for in WP_User::has_cap().
    453  * @param int    $user_id ID of the user being checked against.
    454  * @param array  $args    Miscellaneous arguments passed to the user_has_cap filter.
    455  * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant.
    456  */
    457 function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
    458     _deprecated_function( __FUNCTION__, '7.0.0' );
    459 
    460     // Bail if not checking the 'bp_moderate' cap.
    461     if ( 'bp_moderate' !== $cap ) {
    462         return $caps;
    463     }
    464 
    465     // Bail if BuddyPress is not network activated.
    466     if ( bp_is_network_activated() ) {
    467         return $caps;
    468     }
    469 
    470     // Never trust inactive users.
    471     if ( bp_is_user_inactive( $user_id ) ) {
    472         return $caps;
    473     }
    474 
    475     // Only users that can 'manage_options' on this site can 'bp_moderate'.
    476     return array( 'manage_options' );
    477 }
    478 
    479 /**
    480  * Adds BuddyPress-specific user roles.
    481  *
    482  * This is called on plugin activation.
    483  *
    484  * @since 1.6.0
    485  * @deprecated 1.7.0
    486  */
    487 function bp_add_roles() {
    488     _doing_it_wrong( 'bp_add_roles', esc_html__( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
    489 }
    490 
    491 /**
    492  * Removes BuddyPress-specific user roles.
    493  *
    494  * This is called on plugin deactivation.
    495  *
    496  * @since 1.6.0
    497  * @deprecated 1.7.0
    498  */
    499 function bp_remove_roles() {
    500     _doing_it_wrong( 'bp_remove_roles', esc_html__( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
    501 }
    502 
    503 
    504 /**
    505  * The participant role for registered users without roles.
    506  *
    507  * This is primarily for multisite compatibility when users without roles on
    508  * sites that have global communities enabled.
    509  *
    510  * @since 1.6.0
    511  * @deprecated 1.7.0
    512  */
    513 function bp_get_participant_role() {
    514     _doing_it_wrong( 'bp_get_participant_role', esc_html__( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
    515 }
    516 
    517 /**
    518  * The moderator role for BuddyPress users.
    519  *
    520  * @since 1.6.0
    521  * @deprecated 1.7.0
    522  */
    523 function bp_get_moderator_role() {
    524     _doing_it_wrong( 'bp_get_moderator_role', esc_html__( 'Special community roles no longer exist. Use mapped capabilities instead', 'buddypress' ), '1.7' );
    525 }
     422add_action( 'wp_roles_init', '_bp_roles_init' );
Note: See TracChangeset for help on using the changeset viewer.