bp_xprofile_get_hidden_fields_for_user( int $displayed_user_id, int $current_user_id )

Get the ids of fields that are hidden for this displayed/loggedin user pair.


Description Description

This is the function primarily responsible for profile field visibility. It works by determining the relationship between the displayed_user (ie the profile owner) and the current_user (ie the profile viewer). Then, based on that relationship, we query for the set of fields that should be excluded from the profile loop.

See also See also


Top ↑

Parameters Parameters

$displayed_user_id

(Required) The id of the user the profile fields belong to.

$current_user_id

(Required) The id of the user viewing the profile.


Top ↑

Return Return

(array) An array of field ids that should be excluded from the profile query


Top ↑

Source Source

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

function bp_xprofile_get_hidden_fields_for_user( $displayed_user_id = 0, $current_user_id = 0 ) {
	if ( !$displayed_user_id ) {
		$displayed_user_id = bp_displayed_user_id();
	}

	if ( !$displayed_user_id ) {
		return array();
	}

	if ( !$current_user_id ) {
		$current_user_id = bp_loggedin_user_id();
	}

	// @todo - This is where you'd swap out for current_user_can() checks
	$hidden_levels = bp_xprofile_get_hidden_field_types_for_user( $displayed_user_id, $current_user_id );
	$hidden_fields = bp_xprofile_get_fields_by_visibility_levels( $displayed_user_id, $hidden_levels );

	/**
	 * Filters the ids of fields that are hidden for this displayed/loggedin user pair.
	 *
	 * @since 1.6.0
	 *
	 * @param array $hidden_fields     Array of hidden fields for the displayed/logged in user.
	 * @param int   $displayed_user_id ID of the displayed user.
	 * @param int   $current_user_id   ID of the current user.
	 */
	return apply_filters( 'bp_xprofile_get_hidden_fields_for_user', $hidden_fields, $displayed_user_id, $current_user_id );
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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