bp_set_user_member_type( int $user_id, string $member_type, bool $append = false )

Set type for a member profile.

Description

Set profile types on save_post

Parameters

$user_id

(Required) ID of the user.

$member_type

(Required) profile type.

$append

(Optional) True to append this to existing types for user, false to replace. Default: false.

Default value: false

Return

(See) bp_set_object_terms().

Source

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

function bp_set_user_member_type( $user_id, $member_type, $append = false ) {

	$retval = bp_set_object_terms( $user_id, $member_type, 'bp_member_type', $append );

	// Bust the cache if the type has been updated.
	if ( ! is_wp_error( $retval ) ) {
		wp_cache_delete( $user_id, 'bp_member_member_type' );

		/**
		 * Fires just after a user's profile type has been changed.
		 *
		 * @since BuddyPress (2.2.0)
		 *
		 * @param int    $user_id     ID of the user whose profile type has been updated.
		 * @param string $member_type profile type.
		 * @param bool   $append      Whether the type is being appended to existing types.
		 */
		do_action( 'bp_set_user_member_type', $user_id, $member_type, $append );
	}

	return $retval;
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.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.