BP_REST_Groups_Endpoint::bp_get_group_member_section_title( integer $group_id, integer $user_id )

Return the group member section header while in the groups members loop.

Description

Parameters

$group_id

(Required) Group ID.

$user_id

(Required) User ID.

Return

(string)

Source

File: bp-groups/classes/class-bp-rest-groups-endpoint.php

	public function bp_get_group_member_section_title( $group_id, $user_id ) {

		if ( empty( $group_id ) || empty( $user_id ) ) {
			return;
		}

		$user_group_role_title = bp_get_user_group_role_title( $user_id, $group_id );
		$group_admin           = groups_get_group_admins( $group_id );
		$group_mode            = groups_get_group_mods( $group_id );
		$group_member          = groups_get_group_members( array( 'group_id' => $group_id ) );

		if ( groups_is_user_admin( $user_id, $group_id ) ) {
			if ( isset( $group_admin ) && count( $group_admin ) > 1 ) {
				return get_group_role_label( $group_id, 'organizer_plural_label_name' );
			} else {
				return get_group_role_label( $group_id, 'organizer_singular_label_name' );
			}
		} elseif ( groups_is_user_mod( $user_id, $group_id ) ) {
			if ( isset( $group_mode ) && count( $group_mode ) > 1 ) {
				return get_group_role_label( $group_id, 'moderator_plural_label_name' );
			} else {
				return get_group_role_label( $group_id, 'moderator_singular_label_name' );
			}
		} elseif ( groups_is_user_member( $user_id, $group_id ) ) {
			$member_count = (int) ( isset( $group_member['count'] ) ? $group_member['count'] : 0 );
			if ( $member_count > 1 ) {
				return get_group_role_label( $group_id, 'member_plural_label_name' );
			} else {
				return get_group_role_label( $group_id, 'member_singular_label_name' );
			}
		}

		return $user_group_role_title;

	}

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.