Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/14/2013 03:43:43 PM (6 years ago)
Author:
boonebgorges
Message:

Remove BuddyPress's restriction spaces in user_login

BuddyPress has historically enforced a no-spaces rule on user_login during
user registration. Originally this was rooted in WPMU's own peculiar character
restrictions, and when the MU requirement was dropped, the same restrictions
were carried over to WordPress Single.

However, these restrictions have caused various problems. BP enforced the "no
spaces" rule during registration by simply swapping out spaces with hyphens and
not telling users. This caused immense confusion. Moreover, the restriction
caused problems when bypassing BP's native user registration, as when
integrating with an external authentication service; these external usernames
*can* sometimes have spaces, and certain areas of BuddyPress were not equipped
to deal with them.

This changeset removes the no-spaces restriction from BuddyPress, and hands
off user_login validation to WordPress Multisite when possible (meaning that on
MS, spaces will still not be allowed during native registration). It also
makes the necessary adjustments throughout BuddyPress to ensure that spaces
in user_login will not break related functionality. On a normal setup, BP (and
WP) only use user_login for authentication, but several changes were necessary
to account for "username compatibility mode", where the user_login is displayed
publicly:

  • Refactor the way that activity @-mentions work in username compatibility mode. We now have functions for converting user IDs to "mentionname" (and vice versa) which will produce @-mention-safe versions of user_nicename or user_login, as appropriate.
  • Use proper URL encoding when building and parsing URLs that contain usernames when compatibility mode is enabled.
  • Fix private messaging autocomplete to work with spaces.

See #4622

Fixes #5185

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-template.php

    r7520 r7570  
    584584
    585585                    // Start search at @ symbol and stop search at closing tag delimiter.
    586                     $search_terms     = '@' . bp_core_get_username( $user_id ) . '<';
     586                    $search_terms     = '@' . bp_activity_get_user_mentionname( $user_id ) . '<';
    587587                    $display_comments = 'stream';
    588588                    $user_id = 0;
     
    27192719            return false;
    27202720
    2721         return apply_filters( 'bp_get_send_public_message_link', wp_nonce_url( bp_get_activity_directory_permalink() . '?r=' . bp_get_displayed_user_username() ) );
    2722     }
     2721        return apply_filters( 'bp_get_send_public_message_link', wp_nonce_url( bp_get_activity_directory_permalink() . '?r=' . bp_get_displayed_user_mentionname() ) );
     2722    }
     2723
    27232724
    27242725/**
     
    29202921    }
    29212922
     2923/**
     2924 * Output the mentionname for the displayed user.
     2925 *
     2926 * @since BuddyPress (1.9.0)
     2927 */
     2928function bp_displayed_user_mentionname() {
     2929    echo bp_get_displayed_user_mentionname();
     2930}
     2931    /**
     2932     * Get the mentionname for the displayed user.
     2933     *
     2934     * @since BuddyPress (1.9.0)
     2935     *
     2936     * @return string Mentionname for the displayed user, if available.
     2937     */
     2938    function bp_get_displayed_user_mentionname() {
     2939        return apply_filters( 'bp_get_displayed_user_mentionname', bp_activity_get_user_mentionname( bp_displayed_user_id() ) );
     2940    }
    29222941
    29232942/**
Note: See TracChangeset for help on using the changeset viewer.