Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/02/2026 07:10:26 PM (4 months ago)
Author:
espellcaste
Message:

Switch the function that updates the spam status of the member on multisite configs and deprecate bp_core_update_member_status.

Since WordPress 5.3, the user status is now updated using the globally available wp_update_user() function. So let us use it instead and deprecate bp_core_update_member_status().

It includes some minor Docblock changes.

Props imath.

Closes https://github.com/buddypress/buddypress/pull/434/
See #9173
Fixes #9167

File:
1 edited

Legend:

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

    r14187 r14195  
    107107    return bp_activity_delete( array( 'id' => $activity_id ) );
    108108}
     109
     110/**
     111 * Update the spam status of the member on multisite configs.
     112 *
     113 * @since 5.0.0
     114 * @deprecated 15.0.0
     115 *
     116 * @param int    $user_id The user ID to spam or ham.
     117 * @param string $value   '0' to mark the user as `ham`, '1' to mark as `spam`.
     118 * @return bool
     119 */
     120function bp_core_update_member_status( $user_id = 0, $value = 0 ) {
     121    _deprecated_function( __FUNCTION__, '15.0.0' );
     122
     123    if ( ! is_multisite() || ! $user_id ) {
     124        return false;
     125    }
     126
     127    /**
     128     * The `update_user_status()` function is deprecated since WordPress 5.3.0.
     129     * Continue to use it if WordPress current major version is lower than 5.3.
     130     */
     131    if ( bp_get_major_wp_version() < 5.3 ) {
     132        return update_user_status( $user_id, 'spam', $value );
     133    }
     134
     135    if ( $value ) {
     136        $value = '1';
     137    }
     138
     139    // Otherwise use the replacement function.
     140    $user = wp_update_user(
     141        array(
     142            'ID'   => $user_id,
     143            'spam' => $value,
     144        )
     145    );
     146
     147    if ( is_wp_error( $user ) ) {
     148        return false;
     149    }
     150
     151    return true;
     152}
Note: See TracChangeset for help on using the changeset viewer.