Skip to:
Content

BuddyPress.org

Changeset 4383


Ignore:
Timestamp:
05/18/2011 07:34:06 PM (13 years ago)
Author:
djpaul
Message:

Swap a SQL query for a core function. Also add support for BP_ENABLE_USERNAME_COMPATIBILITY_MODE when fetching userlink by username.

File:
1 edited

Legend:

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

    r4372 r4383  
    443443
    444444/**
    445  * Returns the user link for the user based on user's username
    446  *
    447  * @package BuddyPress Core
    448  * @param $username str The username for the user.
    449  * @uses bp_core_get_userlink() BuddyPress function to get a userlink by user ID.
     445 * Returns the user link for the user based on the supplied identifier
     446 *
     447 * @param $username str If BP_ENABLE_USERNAME_COMPATIBILITY_MODE is set, this will be user_login, otherwise it will be user_nicename.
    450448 * @return str The link to the users home base. False on no match.
    451449 */
    452450function bp_core_get_userlink_by_username( $username ) {
    453     global $wpdb;
    454 
    455     $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) );
     451    if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
     452        $user_id = bp_core_get_userid( $username );
     453    else
     454        $user_id = bp_core_get_userid_from_nicename( $username );
     455
    456456    return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
    457457}
Note: See TracChangeset for help on using the changeset viewer.