Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/17/2012 05:36:46 AM (12 years ago)
Author:
r-a-y
Message:

Fix messages_new_message() so numeric usernames get parsed properly.

Previously to this commit, numeric recipients were being checked
against the user ID column with bp_core_get_core_userdata() only.

This was considered okay since you cannot create a username with only
numbers on the BP frontend registration page. However, you can create
numeric usernames in the WP backend or if the site already uses
numeric usernames via LDAP or some other login system.

So, this commit also checks against user_login / user_nicename with
bp_core_get_userid() / bp_core_get_userid_from_nicename() as well to
be considerate to those use cases.

Fixes #4305.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-messages/bp-messages-functions.php

    r6093 r6340  
    6969        foreach( (array) $recipients as $recipient ) {
    7070            $recipient = trim( $recipient );
     71
    7172            if ( empty( $recipient ) )
    7273                continue;
    7374
     75            $recipient_id = false;
     76
     77            // input was numeric
    7478            if ( is_numeric( $recipient ) ) {
     79                // do a check against the user ID column first
    7580                if ( bp_core_get_core_userdata( (int) $recipient ) )
    7681                    $recipient_id = (int) $recipient;
     82
     83                // if that fails, check against the user_login / user_nicename column
     84                else {
     85                    if ( bp_is_username_compatibility_mode() )
     86                        $recipient_id = bp_core_get_userid( (int) $recipient );
     87                    else
     88                        $recipient_id = bp_core_get_userid_from_nicename( (int) $recipient );
     89                }
    7790
    7891            } else {
Note: See TracChangeset for help on using the changeset viewer.