BP_Group_Extension::get_group_id()

Get the current group ID.


Description Description

Check for:

  • current group
  • new group
  • group admin

Return Return

(int)


Top ↑

Source Source

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

	public static function get_group_id() {

		// Usually this will work.
		$group_id = bp_get_current_group_id();

		// On the admin, get the group id out of the $_GET params.
		if ( empty( $group_id ) && is_admin() && ( isset( $_GET['page'] ) && ( 'bp-groups' === $_GET['page'] ) ) && ! empty( $_GET['gid'] ) ) {
			$group_id = (int) $_GET['gid'];
		}

		// This fallback will only be hit when the create step is very
		// early.
		if ( empty( $group_id ) && bp_get_new_group_id() ) {
			$group_id = bp_get_new_group_id();
		}

		// On some setups, the group id has to be fetched out of the
		// $_POST array
		// @todo Figure out why this is happening during group creation.
		if ( empty( $group_id ) && isset( $_POST['group_id'] ) ) {
			$group_id = (int) $_POST['group_id'];
		}

		return $group_id;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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