bp_get_user_group_role_title( int $user_id = false, int $group_id = false )

Get the member’s group role

Description

Parameters

$user_id

(Optional) ID of the user.

Default value: false

$group_id

(Optional) ID of the group.

Default value: false

Return

(string)

Source

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

function bp_get_user_group_role_title( $user_id = false, $group_id = false ) {

	if ( ! $user_id && ! $group_id )
		return '';

	$role_title = '';

	if ( groups_is_user_admin( $user_id, $group_id ) ) {
		$role_title = __( get_group_role_label( $group_id, 'organizer_singular_label_name' ), 'buddyboss' );
	} elseif ( groups_is_user_mod( $user_id, $group_id ) ) {
		$role_title = __( get_group_role_label( $group_id, 'moderator_singular_label_name' ), 'buddyboss' );
	} elseif ( groups_is_user_member( $user_id, $group_id ) ) {
		$role_title = __( get_group_role_label( $group_id, 'member_singular_label_name' ), 'buddyboss' );
	}

	/**
	 * Filters member's group role title
	 *
	 * @since BuddyBoss 1.0.0
	 *
	 * @param string $role_title User group role title.
	 */
	return apply_filters( 'bp_get_user_group_role_title', $role_title );
}

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.