Skip to:
Content

BuddyPress.org

Changeset 7478


Ignore:
Timestamp:
10/24/2013 10:04:58 PM (12 years ago)
Author:
r-a-y
Message:

Use 'user_nicename' when adding a member via autocomplete in the group
admin dashboard page.

Previously, 'user_login' was used, which is an unsanitized version of the
username. When attempting to add a member with special characters (such
as an email address), the JS would throw an error.

Switching to 'user_nicename' allows a sanitized version of the username to
be used and fixes the issue with the autocomplete JS.

Fixes #5187.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-admin.php

    r7387 r7478  
    234234                // Make sure the user exists before attempting
    235235                // to add to the group
    236                 if ( ! $user_id = username_exists( $un ) ) {
    237                     $error_new[]   = $un;
    238                 } else if ( ! groups_join_group( $group_id, $user_id ) ) {
    239                     $error_new[]   = $un;
     236                $user = get_user_by( 'slug', $un );
     237
     238                if ( empty( $user ) ) {
     239                    $error_new[] = $un;
    240240                } else {
    241                     $success_new[] = $un;
     241                    if ( ! groups_join_group( $group_id, $user->ID ) ) {
     242                        $error_new[]   = $un;
     243                    } else {
     244                        $success_new[] = $un;
     245                    }
    242246                }
    243247            }
     
    978982        $return[] = array(
    979983            /* translators: 1: user_login, 2: user_email */
    980             'label' => sprintf( __( '%1$s (%2$s)' ), $user->user_login, $user->user_email ),
    981             'value' => $user->user_login,
     984            'label' => sprintf( __( '%1$s (%2$s)' ), bp_is_username_compatibility_mode() ? $user->user_login : $user->user_nicename, $user->user_email ),
     985            'value' => $user->user_nicename,
    982986        );
    983987    }
Note: See TracChangeset for help on using the changeset viewer.