Changeset 1230
- Timestamp:
- 03/18/2009 10:32:07 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
bp-core/bp-core-templatetags.php (modified) (1 diff)
-
bp-xprofile.php (modified) (1 diff)
-
bp-xprofile/bp-xprofile-classes.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-templatetags.php
r1229 r1230 232 232 function bp_fetch_user_fullname( $user_id = false, $echo = true ) { 233 233 global $bp; 234 234 235 235 if ( !$user_id ) 236 236 $user_id = $bp->displayed_user->id; 237 238 $ud = get_userdata($user_id);239 $fullname = $ud->bp_fullname;240 241 if ( !$fullname) {242 if ( function_exists('xprofile_install') ) {243 $ fullname = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id);237 238 if ( function_exists('xprofile_install') ) { 239 $data = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id ); 240 241 if ( empty($data) ) { 242 $ud = get_userdata($user_id); 243 $data = xprofile_set_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id, bp_core_ucfirst($ud->user_login) ); 244 244 } else { 245 $ud = get_userdata($user_id); 246 $fullname = $ud->user_login; 245 $data = bp_core_ucfirst($data); 247 246 } 248 249 update_usermeta( $user_id, 'bp_fullname', $fullname ); 250 } 251 247 } else { 248 $ud = get_userdata($user_id); 249 $data = $ud->user_login; 250 } 251 252 252 if ( $echo ) 253 echo apply_filters( 'bp_fetch_user_fullname', stripslashes( trim( $ fullname) ) );253 echo apply_filters( 'bp_fetch_user_fullname', stripslashes( trim( $data ) ) ); 254 254 else 255 return apply_filters( 'bp_fetch_user_fullname', stripslashes ( trim ( $ fullname) ) );255 return apply_filters( 'bp_fetch_user_fullname', stripslashes ( trim ( $data ) ) ); 256 256 } 257 257 -
trunk/bp-xprofile.php
r1227 r1230 830 830 831 831 /** 832 * xprofile_set_field_data() 833 * 834 * A simple function to set profile data for a specific field for a specific user. 835 * 836 * @package BuddyPress Core 837 * @param $field_name The name of the field to set data for. 838 * @param $user_id The ID of the user 839 * @param $value The value for the field you want to set for the user. 840 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 841 * @uses xprofile_get_field_id_from_name() Gets the ID for the field based on the name. 842 * @return true on success, false on failure. 843 */ 844 function xprofile_set_field_data( $field_name, $user_id, $value ) { 845 global $bp; 846 847 if ( !$field_id = xprofile_get_field_id_from_name( $field_name ) ) 848 return false; 849 850 $field = new BP_XProfile_ProfileData(); 851 $field->field_id = $field_id; 852 $field->user_id = $user_id; 853 $field->value = $value; 854 855 return $field->save(); 856 } 857 858 /** 859 * xprofile_get_field_id_from_name() 860 * 861 * Returns the ID for the field based on the field name. 862 * 863 * @package BuddyPress Core 864 * @param $field_name The name of the field to get the ID for. 865 * @return int $field_id on success, false on failure. 866 */ 867 function xprofile_get_field_id_from_name( $field_name ) { 868 return BP_Xprofile_Field::get_id_from_name( $field_name ); 869 } 870 871 /** 832 872 * xprofile_get_random_profile_data() 833 873 * -
trunk/bp-xprofile/bp-xprofile-classes.php
r1224 r1230 966 966 return false; 967 967 } 968 969 function get_id_from_name( $field_name ) { 970 global $wpdb, $bp; 971 972 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", $field_name ) ); 973 } 968 974 } 969 975
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)