个人资料字段循环

个人资料字段循环

Codex Home → Developer Resources → Loops Reference → Profile Fields Loop
Profile Fields Loop

The profile data loop is the most complex out of all the custom BuddyPress loops. It’s actually two loops in one, the first is to loop through profile field groups, and the second to loop through profile fields in that profile field group.
Standard Loop

This user does not have a profile.

Accepted Parameters
The bp_group_has_profile() function will accept a number of parameters that will manipulate the data being returned.

profile_group_id optional
By default all groups and all fields will be displayed. If you provide the ID of a profile field group, then only the fields in this group will be displayed.

Default value: false

user_id optional
The ID of the user you want to fetch the profile data for. This is required if you are outside a member profile URL (/members/andy/…), otherwise it is the ID of the displayed user.

Default value: bp_displayed_user_id()

member_type optional
Limit fields by those restricted to a given member type, or array of  member types. If $user_id is provided, the value of $member_type will be overridden by the member types of the provided user. The special value of ‘any’ will return only those fields that are unrestricted by member type – i.e., those applicable to any type.

Default value: false

hide_empty_groups optional
By default empty groups will not be displayed. If you provide the 0 value, then all the groups will be displayed.

Default value: true

hide_empty_fields optional
By default, only show empty fields if we’re on the Dashboard, or we’re on a user’s profile edit page, or this is a registration page. If you provide the 0 value, then all the fields will be displayed on your page.

Default value: !is_network_admin() && !is_admin() && !bp_is_user_profile_edit() && !bp_is_register_page()

fetch_fields optional
Whether to fetch each group’s fields.

Default value: false

fetch_fields_data optional
Whether to fetch data for each field. Requires a $user_id.

Default value: false

exclude_groups optional
Comma-separated list or array of group IDs to exclude.

Default value: array()

exclude_fields optional
Comma-separated list or array of field IDs to exclude.

Default value: array()

update_meta_cache optional
Whether to pre-fetch xprofilemeta for all retrieved groups, fields, and data.

Default value: true

Advanced Usage
Fetch all the profile data for the user with ID 10.

Fetch the profile data for fields in the profile group ID 2 for the user with ID 10.

Fetch the profile data for fields in the profile group ID 2.

Fetch all the profile data, even empty fieds and groups, for current user.

Fetch all the profile data for the user with ID 10, excluding fields with ID 5, 6, 7.

上次修改 2021.12.31