Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/06/2014 07:38:35 PM (11 years ago)
Author:
boonebgorges
Message:

Introduce bp_xprofile_fullname_field_id() and use in query building throughout BP

There are many places throughout BuddyPress where it's necessary to query for
user fullnames. When XProfile is active, part of this process involves
determining the ID of the fullname field. Historically, this has been done by
querying for the ID of a field corresponding to the 'name' bp_xprofile_fullname_field_name().
Creating a standalone function for this allows us to centralize persistent
caching for the field ID.

As a side note, the fact that we do this query at all is a little farcical.
The fullname field is essentially necessarily tied to field #1 (due to some
hardcoding in the xprofile schema definition as well as bp-xprofile-admin.php).
We rely on the Name setting only for historical reasons, which probably didn't
even make all that much sense at the time. At some point, a serious review
should be done, and references to the fullname field id standardized (either
all hardcoded, or all not hardcoded).

See #5362

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-classes.php

    r7800 r7812  
    302302                // the xprofile table
    303303                } else {
    304                     $fullname_field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) );
    305 
    306304                    $this->uid_name = 'user_id';
    307305                    $sql['select']  = "SELECT u.{$this->uid_name} as id FROM {$bp->profile->table_name_data} u";
    308                     $sql['where'][] = "u.field_id = {$fullname_field_id}";
     306                    $sql['where'][] = $wpdb->prepare( "u.field_id = %d", bp_xprofile_fullname_field_id() );
    309307                    $sql['orderby'] = "ORDER BY u.value";
    310308                    $sql['order']   = "ASC";
Note: See TracChangeset for help on using the changeset viewer.