bp_has_profile( array|string $args = '' )

Query for XProfile groups and fields.


Description Description

See also See also


Top ↑

Parameters Parameters

$args

(array|string) (Optional) Array of arguments. See BP_XProfile_Group::get() for full description. Those arguments whose defaults differ from that method are described here:

  • 'user_id'
    (int) Default: ID of the displayed user.
  • 'member_type'
    (string|array) Default: 'any'.
  • 'profile_group_id'
    (int|bool) Default: false.
  • 'hide_empty_groups'
    (bool) Default: true.
  • 'hide_empty_fields'
    (bool) Defaults to true on the Dashboard, on a user's Edit Profile page, or during registration. Otherwise false.
  • 'fetch_fields'
    (bool) Default: true.
  • 'fetch_field_data'
    (bool) Default: true.
  • 'fetch_visibility_level'
    (bool) Defaults to true when an admin is viewing a profile, or when a user is viewing her own profile, or during registration. Otherwise false.
  • 'exclude_groups'
    (int[]|bool) Default: false.
  • 'exclude_fields'
    (int[]|bool) Default: false.
  • 'hide_field_types'
    (string[]) Default: empty array.
  • 'signup_fields_only'
    (bool) Default: false.
  • 'update_meta_cache'
    (bool) Default: true.

Default value: ''


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: bp-xprofile/bp-xprofile-template.php

function bp_has_profile( $args = '' ) {
	global $profile_template;

	// 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.
	$hide_empty_fields_default = ( ! is_network_admin() && ! is_admin() && ! bp_is_user_profile_edit() && ! bp_is_register_page() );

	// We only need to fetch visibility levels when viewing your own profile.
	if ( bp_is_my_profile() || bp_current_user_can( 'bp_moderate' ) || bp_is_register_page() ) {
		$fetch_visibility_level_default = true;
	} else {
		$fetch_visibility_level_default = false;
	}

	// Parse arguments.
	$r = bp_parse_args( $args, array(
		'user_id'                => bp_displayed_user_id(),
		'member_type'            => 'any',
		'profile_group_id'       => false,
		'hide_empty_groups'      => true,
		'hide_empty_fields'      => $hide_empty_fields_default,
		'fetch_fields'           => true,
		'fetch_field_data'       => true,
		'fetch_visibility_level' => $fetch_visibility_level_default,
		'exclude_groups'         => false, // Comma-separated list of profile field group IDs to exclude.
		'exclude_fields'         => false, // Comma-separated list of profile field IDs to exclude.
		'hide_field_types'       => array(), // List of field types to hide from profile fields loop.
		'signup_fields_only'     => false, // Whether to only return signup fields.
		'update_meta_cache'      => true,
	), 'has_profile' );

	// Populate the template loop global.
	$profile_template = new BP_XProfile_Data_Template( $r );

	/**
	 * Filters whether or not a group has a profile to display.
	 *
	 * @since 1.1.0
	 * @since 2.6.0 Added the `$r` parameter.
	 *
	 * @param bool   $has_groups       Whether or not there are group profiles to display.
	 * @param string $profile_template Current profile template being used.
	 * @param array  $r                Array of arguments passed into the BP_XProfile_Data_Template class.
	 */
	return apply_filters( 'bp_has_profile', $profile_template->has_groups(), $profile_template, $r );
}


Top ↑

Changelog Changelog

Changelog
Version Description
8.0.0 Introduced $hide_field_types & $signup_fields_only arguments.
2.4.0 Introduced $member_type argument.
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.