bp_has_member_type( int $user_id, string $member_type )

Check whether the given user has a certain profile type.

Description

Parameters

$user_id

(Required) $user_id ID of the user.

$member_type

(Required) profile type.

Return

(bool) Whether the user has the given profile type.

Source

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

function bp_has_member_type( $user_id, $member_type ) {
	// Bail if no valid profile type was passed.
	if ( empty( $member_type ) || ! bp_get_member_type_object( $member_type ) ) {
		return false;
	}

	// Get all user's profile types.
	$types = bp_get_member_type( $user_id, false );

	if ( ! is_array( $types ) ) {
		return false;
	}

	return in_array( $member_type, $types );
}

Changelog

Changelog
Version Description
BuddyPress 2.3.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.