Changeset 8083
- Timestamp:
- 03/08/2014 12:39:35 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-members/bp-members-template.php
r8082 r8083 655 655 } 656 656 657 /** 658 * Output a piece of user profile data. 659 * 660 * @see bp_get_member_profile_data() for a description of params. 661 * 662 * @param array $args See {@link bp_get_member_profile_data()}. 663 */ 657 664 function bp_member_profile_data( $args = '' ) { 658 665 echo bp_get_member_profile_data( $args ); 659 666 } 667 /** 668 * Get a piece of user profile data. 669 * 670 * When used in a bp_has_members() loop, this function will attempt 671 * to fetch profile data cached in the template global. It is also safe 672 * to use outside of the loop. 673 * 674 * @param array $args { 675 * Array of config paramaters. 676 * @type string $field Name of the profile field. 677 * @type int $user_id ID of the user whose data is being fetched. 678 * Defaults to the current member in the loop, or if not 679 * present, to the currently displayed user. 680 * } 681 * @return string|bool Profile data if found, otherwise false. 682 */ 660 683 function bp_get_member_profile_data( $args = '' ) { 661 684 global $members_template; 662 685 663 if ( ! bp_is_active( 'xprofile' ) )686 if ( ! bp_is_active( 'xprofile' ) ) { 664 687 return false; 688 } 665 689 666 690 // Declare local variables … … 669 693 // Guess at default $user_id 670 694 $default_user_id = 0; 671 if ( ! empty( $members_template->member->id ) )695 if ( ! empty( $members_template->member->id ) ) { 672 696 $default_user_id = $members_template->member->id; 673 elseif ( bp_displayed_user_id() )697 } elseif ( bp_displayed_user_id() ) { 674 698 $default_user_id = bp_displayed_user_id(); 699 } 675 700 676 701 $defaults = array( … … 680 705 681 706 $r = wp_parse_args( $args, $defaults ); 682 extract( $r, EXTR_SKIP );683 707 684 708 // If we're in a members loop, get the data from the global … … 689 713 // Otherwise query for the data 690 714 if ( empty( $profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ) ) { 691 $profile_data = BP_XProfile_ProfileData::get_all_for_user( $ user_id);715 $profile_data = BP_XProfile_ProfileData::get_all_for_user( $r['user_id'] ); 692 716 } 693 717 … … 698 722 } 699 723 700 // Get the field data if there is data to get 701 if ( ! empty( $profile_data ) && ! empty( $profile_data[ $field ]['field_type'] ) && ! empty( $profile_data[ $field ]['field_data'] ) ) 702 $data = xprofile_format_profile_field( $profile_data[ $field ]['field_type'], $profile_data[ $field ]['field_data'] ); 724 // Get the data for the specific field requested 725 if ( ! empty( $profile_data ) && ! empty( $profile_data[ $r['field'] ]['field_type'] ) && ! empty( $profile_data[ $r['field'] ]['field_data'] ) ) { 726 $data = xprofile_format_profile_field( $profile_data[ $r['field'] ]['field_type'], $profile_data[ $r['field'] ]['field_data'] ); 727 } 703 728 704 729 return apply_filters( 'bp_get_member_profile_data', $data );
Note: See TracChangeset
for help on using the changeset viewer.