Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/24/2020 12:20:39 PM (4 years ago)
Author:
imath
Message:

Administration: add support for multiple member types assignment

Community Administrators can now use the multiple select box of the User's Extended Profile Member Type metabox to assign one or more Member Types to the user.

Data for the Member Type column of the WP Users List Table are now displaying a comma separated list of Member Types for Users being assigned to more than one Member Type (which was the original ticket's need).

The bulk removing or assigning member types functionalities have been improved to behave as follows :

  • Bulk removing member types is removing all assigned member types.
  • Bulk assigning a member type is replacing all assigned member types with the selected member type.

Props etatus, vapvarun

Fixes #8292

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-functions.php

    r12754 r12765  
    29942994 *
    29952995 * @since 2.2.0
    2996  *
    2997  * @param int    $user_id     ID of the user.
    2998  * @param string $member_type Member type.
    2999  * @param bool   $append      Optional. True to append this to existing types for user,
    3000  *                            false to replace. Default: false.
     2996 * @since 7.0.0 $member_type parameter also accepts an array of member type names.
     2997 *
     2998 * @param int          $user_id     ID of the user.
     2999 * @param string|array $member_type The member type name or an array of member type names.
     3000 * @param bool         $append      Optional. True to append this to existing types for user,
     3001 *                                  false to replace. Default: false.
    30013002 * @return false|array $retval See {@see bp_set_object_terms()}.
    30023003 */
    30033004function bp_set_member_type( $user_id, $member_type, $append = false ) {
    30043005    // Pass an empty $member_type to remove a user's type.
    3005     if ( ! empty( $member_type ) && ! bp_get_member_type_object( $member_type ) ) {
    3006         return false;
     3006    if ( ! empty( $member_type ) ) {
     3007        $member_types = (array) $member_type;
     3008        $valid_types  = array_filter( array_map( 'bp_get_member_type_object', $member_types ) );
     3009
     3010        if ( $valid_types ) {
     3011            $member_type = wp_list_pluck( $valid_types, 'name' );
     3012        } else {
     3013            return false;
     3014        }
    30073015    }
    30083016
     
    30183026         * @since 2.2.0
    30193027         *
    3020          * @param int    $user_id     ID of the user whose member type has been updated.
    3021          * @param string $member_type Member type.
    3022          * @param bool   $append      Whether the type is being appended to existing types.
     3028         * @param int          $user_id     ID of the user whose member type has been updated.
     3029         * @param string|array $member_type The member type name or an array of member type names.
     3030         * @param bool         $append      Whether the type is being appended to existing types.
    30233031         */
    30243032        do_action( 'bp_set_member_type', $user_id, $member_type, $append );
     
    31233131     * @since 2.2.0
    31243132     *
    3125      * @param string $type    Member type.
    3126      * @param int    $user_id ID of the user.
    3127      * @param bool   $single  Whether to return a single type string, or an array.
     3133     * @param string|array|bool $type    a single member type (if $single is true) or an array of member types
     3134     *                                   (if $single is false) or false on failure.
     3135     * @param int               $user_id ID of the user.
     3136     * @param bool              $single  Whether to return a single type string, or an array.
    31283137     */
    31293138    return apply_filters( 'bp_get_member_type', $type, $user_id, $single );
Note: See TracChangeset for help on using the changeset viewer.