bp_get_member_type_key( $post_id )

Return profile type key.

Description

Parameters

$post_id

(Required)

Return

(mixed|string)

Source

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

function bp_get_member_type_key( $post_id ) {

	if ( empty( $post_id) ) {
		return '';
	}

	$key = get_post_meta( $post_id, '_bp_member_type_key', true );

	// Fallback to legacy way of generating profile type key from singular label
	// if Key is not set by admin user
	if ( empty( $key ) ) {
		$key = get_post_field( 'post_name', $post_id );
		$term = term_exists( sanitize_key( $key ), bp_get_member_type_tax_name() );
		if ( 0 !== $term && null !== $term ) {
			$digits = 3;
			$unique = rand(pow(10, $digits-1), pow(10, $digits)-1);
			$key = $key.$unique;
		}
		update_post_meta( $post_id, '_bp_member_type_key', sanitize_key( $key ) );
	}

	return apply_filters( 'bp_get_member_type_key', $key );
}

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.