BP_Groups_Group::get_id_by_previous_slug( string $slug )

Get whether a group exists for an old slug.


Description Description


Parameters Parameters

$slug

(Required) Slug to check.


Top ↑

Return Return

(int|null|false) Group ID if found; null if not; false if missing parameters.


Top ↑

Source Source

File: bp-groups/classes/class-bp-groups-group.php

	public static function get_id_by_previous_slug( $slug ) {
		global $wpdb;

		if ( empty( $slug ) ) {
			return false;
		}

		$args = array(
			'meta_query'         => array(
				array(
					'key'   => 'previous_slug',
					'value' => $slug
				),
			),
			'orderby'            => 'meta_id',
			'order'              => 'DESC',
			'per_page'           => 1,
			'page'               => 1,
			'update_meta_cache'  => false,
			'show_hidden'        => true,
		);
		$groups = BP_Groups_Group::get( $args );

		$group_id = null;
		if ( $groups['groups'] ) {
			$group_id = current( $groups['groups'] )->id;
		}

		return $group_id;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.9.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.