diff --git src/bp-groups/bp-groups-functions.php src/bp-groups/bp-groups-functions.php
index 61a732aa6..2fbd1c79a 100644
--- src/bp-groups/bp-groups-functions.php
+++ src/bp-groups/bp-groups-functions.php
@@ -114,12 +114,32 @@ function bp_get_group( $group = false ) {
 
 	if ( $group instanceof BP_Groups_Group ) {
 		$group_obj = $group;
-	} elseif ( is_string( $group ) ) {
-		$group_obj = bp_get_group_by( 'slug', $group );
-	} elseif ( is_numeric( $group ) ) {
-		$group_obj = bp_get_group_by( 'id', $group );
-	} elseif ( isset( $groups_template->group ) && is_object( $groups_template->group ) ) {
+
+		// Nothing requested? Let's use the current Group of the Groups Loop, if available.
+	} elseif ( ! $group && isset( $groups_template->group ) && is_object( $groups_template->group ) ) {
 		$group_obj = $groups_template->group;
+	} else {
+		$current_group = null;
+
+		// Let's get the current group if we can.
+		if ( did_action( 'bp_groups_set_current_group' ) ) {
+			$current_group = groups_get_current_group();
+		}
+
+		$field = '';
+		if ( is_string( $group ) ) {
+			$field = 'slug';
+		} elseif ( is_numeric( $group ) ) {
+			$field = 'id';
+			$group = (int) $group;
+		}
+
+		// Let's use the current Group if it matches with the requested field value.
+		if ( isset( $current_group->{$field} ) && $current_group->{$field} === $group ) {
+			$group_obj = $current_group;
+		} else {
+			$group_obj = bp_get_group_by( $field, $group );
+		}
 	}
 
 	return $group_obj;
@@ -572,20 +592,8 @@ function groups_get_id_by_previous_slug( $group_slug ) {
  * @return bool True on success, false on failure.
  */
 function groups_leave_group( $group, $user_id = 0 ) {
-
-	$current_group = null;
-
-	if ( is_numeric( $group ) ) {
-		$current_group = groups_get_current_group();
-
-		if ( $current_group instanceof BP_Groups_Group && (int) $current_group->id === (int) $group ) {
-			$group = $current_group;
-		}
-	}
-
-	if ( ! isset( $group->id ) ) {
-		$group = bp_get_group( $group );
-	}
+	// Get the group object.
+	$group = bp_get_group( $group );
 
 	if ( empty( $group->id ) ) {
 		return false;
@@ -636,16 +644,8 @@ function groups_leave_group( $group, $user_id = 0 ) {
  * @return bool True on success, false on failure.
  */
 function groups_join_group( $group, $user_id = 0 ) {
-
-	$current_group = null;
-
-	if ( is_numeric( $group ) ) {
-		$current_group = groups_get_current_group();
-
-		if ( $current_group instanceof BP_Groups_Group && (int) $current_group->id === (int) $group ) {
-			$group = $current_group;
-		}
-	}
+	// Get the group object.
+	$group = bp_get_group( $group );
 
 	if ( ! isset( $group->id ) ) {
 		$group = bp_get_group( $group );
@@ -726,21 +726,8 @@ function groups_join_group( $group, $user_id = 0 ) {
  * @return bool False on failure.
  */
 function groups_update_last_activity( $group = 0 ) {
-
-	$current_group = null;
-
-	if ( is_numeric( $group ) ) {
-		$group_id      = (int) $group;
-		$current_group = groups_get_current_group();
-
-		if ( $current_group instanceof BP_Groups_Group && (int) $current_group->id === $group_id ) {
-			$group = $current_group;
-		}
-	}
-
-	if ( ! isset( $group->id ) ) {
-		$group = bp_get_group( $group );
-	}
+	// Get the group object.
+	$group = bp_get_group( $group );
 
 	if ( empty( $group->id ) ) {
 		return false;
diff --git src/bp-groups/classes/class-bp-groups-component.php src/bp-groups/classes/class-bp-groups-component.php
index c8c9b7787..8d4d35eb5 100644
--- src/bp-groups/classes/class-bp-groups-component.php
+++ src/bp-groups/classes/class-bp-groups-component.php
@@ -265,6 +265,9 @@ class BP_Groups_Component extends BP_Component {
 				$this->current_group = apply_filters( 'bp_groups_current_group_object', new $current_group_class( $group_id ) );
 			}
 
+			// Make sure the Group ID is an integer.
+			$this->current_group->id = (int) $this->current_group->id;
+
 			// When in a single group, the first action is bumped down one because of the
 			// group name, so we need to adjust this and set the group name to current_item.
 			$bp->current_item   = bp_current_action();
@@ -280,12 +283,21 @@ class BP_Groups_Component extends BP_Component {
 
 			// If the user is not an admin, check if they are a moderator.
 			if ( ! bp_is_item_admin() ) {
-				bp_update_is_item_mod  ( groups_is_user_mod  ( bp_loggedin_user_id(), $this->current_group->id ), 'groups' );
+				bp_update_is_item_mod( groups_is_user_mod( bp_loggedin_user_id(), $this->current_group->id ), 'groups' );
 			}
 
 			// Check once if the current group has a custom front template.
 			$this->current_group->front_template = bp_groups_get_front_template( $this->current_group );
 
+			/**
+			 * Fires once the `current_group` global is fully set.
+			 *
+			 * @since 10.0.0
+			 *
+			 * @param BP_Groups_Group|object $current_group The current group object.
+			 */
+			do_action_ref_array( 'bp_groups_set_current_group', array( $this->current_group ) );
+
 			// Initialize the nav for the groups component.
 			$this->nav = new BP_Core_Nav( $this->current_group->id );
 
diff --git tests/phpunit/testcases/groups/functions.php tests/phpunit/testcases/groups/functions.php
index e82efd86e..208378547 100644
--- tests/phpunit/testcases/groups/functions.php
+++ tests/phpunit/testcases/groups/functions.php
@@ -330,14 +330,16 @@ class BP_Tests_Groups_Functions extends BP_UnitTestCase {
 		groups_join_group( $g1, $u2 );
 		groups_join_group( $g1, $u3 );
 
-		$this->set_current_user( $u1 );
-
 		$this->assertEquals( 3, groups_get_total_member_count( $g1 ) );
 		$this->assertEquals( 3, BP_Groups_Group::get_total_member_count( $g1 ) );
 
+		add_filter( 'bp_remove_user_data_on_delete_user_hook', '__return_true' );
+
 		// Delete user.
 		wp_delete_user( $u2 );
 
+		remove_filter( 'bp_remove_user_data_on_delete_user_hook', '__return_true' );
+
 		$this->assertEquals( 2, groups_get_total_member_count( $g1 ) );
 		$this->assertEquals( 2, BP_Groups_Group::get_total_member_count( $g1 ) );
 	}
diff --git tests/phpunit/testcases/groups/functions/get-group.php tests/phpunit/testcases/groups/functions/get-group.php
index c86240832..0ae4c31d0 100644
--- tests/phpunit/testcases/groups/functions/get-group.php
+++ tests/phpunit/testcases/groups/functions/get-group.php
@@ -22,11 +22,17 @@ class BP_Tests_Get_Groups_Param extends BP_UnitTestCase {
 		parent::tearDown();
 	}
 
+	/**
+	 * @group bp_get_group
+	 */
 	public function test_bp_get_group_with_no_group() {
 		$this->assertFalse( bp_get_group() );
 		$this->assertFalse( bp_get_group_by( 'id', 0 ) );
 	}
 
+	/**
+	 * @group bp_get_group
+	 */
 	public function test_bp_get_group_with_id() {
 		$g = $this->factory->group->create();
 
@@ -35,6 +41,9 @@ class BP_Tests_Get_Groups_Param extends BP_UnitTestCase {
 		$this->assertSame( $g, bp_get_group_by( 'ID', $g )->id );
 	}
 
+	/**
+	 * @group bp_get_group
+	 */
 	public function test_bp_get_group_with_slug() {
 		$slug = 'test-group';
 		$g    = $this->factory->group->create( array( 'slug' => $slug ) );
@@ -49,19 +58,47 @@ class BP_Tests_Get_Groups_Param extends BP_UnitTestCase {
 		$this->assertSame( $slug, $g2->slug );
 	}
 
+	/**
+	 * @group bp_get_group
+	 */
 	public function test_bp_get_group_with_object() {
 		$g = $this->factory->group->create_and_get();
 
 		$this->assertSame( $g->id, bp_get_group( $g )->id );
 	}
 
+	/**
+	 * @group bp_get_group
+	 */
 	public function test_bp_get_group_from_groups_template() {
 		$g = $this->factory->group->create( array( 'status' => 'private' ) );
 
-		// Fake the current group.
-		$GLOBALS['groups_template'] = new stdClass;
-		$GLOBALS['groups_template']->group = groups_get_group( $g );
+		if ( bp_has_groups( array( 'include' => array( $g ) ) ) ) {
+			while ( bp_groups() ) {
+				bp_the_group();
+				$group = bp_get_group();
+			}
+		}
+
+		$this->assertSame( $g, $group->id );
+	}
+
+	/**
+	 * @group bp_get_group
+	 */
+	public function test_bp_get_group_from_current_group() {
+		$bp = buddypress();
+		$g  = $this->factory->group->create_and_get( array( 'name' => 'foo' ) );
+
+		// Set the current group.
+		$bp->groups->current_group = $g;
+
+		// Change the name to check the current group was used.
+		$bp->groups->current_group->name = 'bar';
+
+		// Override the name
+		do_action( 'bp_groups_set_current_group' );
 
-		$this->assertSame( $g, bp_get_group()->id );
+		$this->assertSame( 'bar', bp_get_group( $g->id )->name );
 	}
 }
