Skip to:
Content

BuddyPress.org

Changeset 12778


Ignore:
Timestamp:
11/10/2020 06:10:54 PM (3 weeks ago)
Author:
imath
Message:

Make Member Types Admin UI more consistent with the Group Types one

Replace the select multiple control with checkboxes into the WP-Admin/Extended profile screen.

Props vapvarun

Fixes #8389

Location:
trunk/src/bp-members
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/admin/css/admin-rtl.css

    r12765 r12778  
    2020div#community-profile-page #profile-nav {
    2121    margin-bottom: 1em;
    22 }
    23 
    24 div#community-profile-page #bp-members-profile-member-type {
    25     width: 100%;
    2622}
    2723
  • trunk/src/bp-members/admin/css/admin.css

    r12765 r12778  
    2020div#community-profile-page #profile-nav {
    2121    margin-bottom: 1em;
    22 }
    23 
    24 div#community-profile-page #bp-members-profile-member-type {
    25     width: 100%;
    2622}
    2723
  • trunk/src/bp-members/classes/class-bp-members-admin.php

    r12765 r12778  
    12881288
    12891289        $types        = bp_get_member_types( array(), 'objects' );
    1290         $current_type = bp_get_member_type( $user->ID, false );
     1290        $current_type = (array) bp_get_member_type( $user->ID, false );
     1291        $types_count  = count( array_filter( $current_type ) );
    12911292        ?>
    12921293
     
    12971298            ?>
    12981299        </label>
    1299         <select name="bp-members-profile-member-type[]" id="bp-members-profile-member-type" multiple="multiple">
    1300             <option value="" <?php selected( ! $current_type ); ?>>
    1301                 <?php
    1302                     /* translators: no option picked in select box */
    1303                     esc_attr_e( '----', 'buddypress' );
    1304                 ?>
    1305             </option>
     1300        <ul class="categorychecklist form-no-clear">
    13061301            <?php foreach ( $types as $type ) : ?>
    1307                 <option value="<?php echo esc_attr( $type->name ) ?>" <?php selected( in_array( $type->name, (array) $current_type, true ) ) ?>><?php echo esc_html( $type->labels['singular_name'] ) ?></option>
     1302                <li>
     1303                    <label class="selectit">
     1304                        <input value="<?php echo esc_attr( $type->name ) ?>" name="bp-members-profile-member-type[]" type="checkbox" <?php checked( true, in_array( $type->name, $current_type ) ); ?>>
     1305                        <?php echo esc_html( $type->labels['singular_name'] ); ?>
     1306                    </label>
     1307                </li>
    13081308            <?php endforeach; ?>
    1309         </select>
     1309            <input type="hidden" value="<?php echo intval( $types_count ); ?>" name="bp-members-profile-member-types-count" />
     1310        </ul>
    13101311
    13111312        <?php
     
    13191320     */
    13201321    public function process_member_type_update() {
    1321         if ( ! isset( $_POST['bp-member-type-nonce'] ) || ! isset( $_POST['bp-members-profile-member-type'] ) ) {
     1322        if ( ! isset( $_POST['bp-member-type-nonce'] ) || ! isset( $_POST['bp-members-profile-member-types-count'] ) ) {
    13221323            return;
    13231324        }
     
    13321333        }
    13331334
    1334         // Member type [string] must either reference a valid member type, or be empty.
    1335         $member_type = wp_parse_slug_list( wp_unslash( $_POST['bp-members-profile-member-type'] ) );
    1336         $member_type = array_filter( $member_type );
     1335        if ( isset( $_POST['bp-members-profile-member-type'] ) ) {
     1336            // Member type [string] must either reference a valid member type, or be empty.
     1337            $member_type = wp_parse_slug_list( wp_unslash( $_POST['bp-members-profile-member-type'] ) );
     1338            $member_type = array_filter( $member_type );
     1339        } elseif ( 0 !== intval( $_POST['bp-members-profile-member-types-count'] ) ) {
     1340            $member_type = false;
     1341        }
     1342
     1343        // Nothing to do there.
     1344        if ( ! isset( $member_type ) ) {
     1345            return;
     1346        }
    13371347
    13381348        /*
Note: See TracChangeset for help on using the changeset viewer.