bp_groups_exclude_group_type( bool $qs = false, bool $object = false )

Excludes specific group types from search and listing.

Description

Parameters

$qs

(Optional)

Default value: false

$object

(Optional)

Default value: false

Return

(bool|string)

Source

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

function bp_groups_exclude_group_type( $qs = false, $object = false ) {

	$args = wp_parse_args( $qs );

	if ( $object !== 'groups' ) {
		return $qs;
	}

	if ( bp_is_groups_directory() && isset( $args['scope'] ) && 'all' === $args['scope'] ) {

		// get removed group type post ids
		$bp_group_type_ids = bp_groups_get_excluded_group_types();

		// get removed group type names/slugs
		$bp_group_type_names = array();
		if ( isset( $bp_group_type_ids ) && ! empty( $bp_group_type_ids ) ) {
			foreach ( $bp_group_type_ids as $single ) {
				$bp_group_type_names[] = $single['name'];
			}
		}

		if ( ! empty( $args['group_type__not_in'] ) ) {
			if ( is_array( $args['group_type__not_in'] ) ) {
				$args['group_type__not_in'] = array_merge( $args['group_type__not_in'], $bp_group_type_names );
			} else {
				$args['group_type__not_in'] = $args['group_type__not_in'] . ',' . implode( ',', $bp_group_type_names );
			}
		} else {
			$args['group_type__not_in'] = implode( ',', $bp_group_type_names );
		}

		$qs = build_query( $args );
	}

	return $qs;
}

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.