Skip to:
Content

BuddyPress.org

Changeset 4634


Ignore:
Timestamp:
07/09/2011 10:13:15 PM (13 years ago)
Author:
boonebgorges
Message:

Introduces bp_xprofile_fullname_field_name() to avoid referencing BP_XPROFILE_FULLNAME_FIELD_NAME throughout BuddyPress. See #3314

Location:
trunk
Files:
4 edited

Legend:

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

    r4558 r4634  
    144144        global $bp;
    145145
     146        $full_name_field_name = bp_xprofile_fullname_field_name();
     147
    146148        if ( bp_is_active( 'xprofile' ) )
    147149            $this->profile_data = $this->get_profile_data();
     
    149151        if ( $this->profile_data ) {
    150152            $this->user_url  = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
    151             $this->fullname  = esc_attr( $this->profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );
     153            $this->fullname  = esc_attr( $this->profile_data[$full_name_field_name]['field_data'] );
    152154            $this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
    153155            $this->email     = esc_attr( $this->profile_data['user_email'] );
     
    380382        $exclude_sql = ( !empty( $exclude ) ) ? " AND u.ID NOT IN ({$exclude})" : "";
    381383
    382         $total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE '$letter%%'  ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter );
    383         $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}", BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter, $pag_sql );
     384        $total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE '$letter%%'  ORDER BY pd.value ASC", bp_xprofile_fullname_field_name() ), $letter );
     385        $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM {$wpdb->users} u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}", bp_xprofile_fullname_field_name() ), $letter, $pag_sql );
    384386
    385387        $total_users = $wpdb->get_var( $total_users_sql );
     
    507509        // Fetch the user's full name
    508510        if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) {
    509             $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", BP_XPROFILE_FULLNAME_FIELD_NAME ) );
     511            $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", bp_xprofile_fullname_field_name() ) );
    510512            for ( $i = 0; $i < count( $paged_users ); $i++ ) {
    511513                foreach ( (array)$names as $name ) {
  • trunk/bp-friends/bp-friends-classes.php

    r4558 r4634  
    272272            return false;
    273273
    274         return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->profile->table_name_data} pd, {$bp->profile->table_name_fields} pf WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} ) ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ) );
     274        return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->profile->table_name_data} pd, {$bp->profile->table_name_fields} pf WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} ) ORDER BY pd.value ASC", bp_xprofile_fullname_field_name() ) );
    275275    }
    276276
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r4452 r4634  
    984984            $user_id = $bp->displayed_user->id;
    985985
    986         $data = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id );
    987 
    988         return $data[BP_XPROFILE_FULLNAME_FIELD_NAME];
     986        $field_name = bp_xprofile_fullname_field_name();
     987
     988        $data = xprofile_get_field_data( $field_name, $user_id );
     989
     990        return $data[$field_name];
    989991    }
    990992}
  • trunk/bp-xprofile/bp-xprofile-functions.php

    r4632 r4634  
    386386        return false;
    387387
    388     $fullname = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id );
     388    $fullname = xprofile_get_field_data( bp_xprofile_fullname_field_name(), $user_id );
    389389    $space    = strpos( $fullname, ' ' );
    390390
     
    419419        return;
    420420
    421     xprofile_set_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user->ID, $user->display_name );
     421    xprofile_set_field_data( bp_xprofile_fullname_field_name(), $user->ID, $user->display_name );
    422422}
    423423add_action( 'user_profile_update_errors', 'xprofile_sync_bp_profile', 10, 3 );
     
    579579    return bp_xprofile_update_meta( $field_data_id, 'data', $meta_key, $meta_value );
    580580}
     581
     582/**
     583 * Return the field name for the Full Name xprofile field
     584 *
     585 * @package BuddyPress
     586 * @since 1.3
     587 *
     588 * @return str The field name
     589 */
     590function bp_xprofile_fullname_field_name() {
     591    return apply_filters( 'bp_xprofile_fullname_field_name', BP_XPROFILE_FULLNAME_FIELD_NAME );
     592}
     593
    581594?>
Note: See TracChangeset for help on using the changeset viewer.