Index: src/bp-groups/bp-groups-template.php
===================================================================
--- src/bp-groups/bp-groups-template.php
+++ src/bp-groups/bp-groups-template.php
@@ -1645,34 +1645,52 @@
 /**
  * Checks if a user is banned from a group.
  *
- * If this function is invoked inside the groups template loop (e.g. the group directory), then
- * check $groups_template->group->is_banned instead of making another SQL query.
- * However, if used in a single group's pages, we must use groups_is_user_banned().
+ * If this function is invoked inside the groups template loop (e.g. the group
+ * directory), then check $groups_template->group->is_banned instead of making
+ * another SQL query. However, if used in a single group's pages, we must use
+ * groups_is_user_banned().
+ *
+ * @since BuddyPress (1.5.0)
  *
  * @global BP_Groups_Template $groups_template Group template loop object
- * @param object $group Group to check if user is banned from the group
- * @param int $user_id
- * @return bool If user is banned from the group or not
- * @since BuddyPress (1.5)
+ * @param BP_Groups_Group $group Group to check if user is banned
+ * @param int $user_id The user ID to check
+ * @return mixed Boolean true or string '1' if user is banned.  Boolean false
+ *         or string '0' if user isn't banned. null if user isn't a member of
+ *         the group when groups_is_user_banned() is called.
  */
 function bp_group_is_user_banned( $group = false, $user_id = 0 ) {
 	global $groups_template;
 
 	// Site admins always have access
-	if ( bp_current_user_can( 'bp_moderate' ) )
+	if ( bp_current_user_can( 'bp_moderate' ) ) {
 		return false;
+	}
 
-	if ( empty( $group ) ) {
-		$group =& $groups_template->group;
+	// check groups loop first
+	// @see BP_Groups_Group::get_group_extras()
+	if ( ! empty( $groups_template->in_the_loop ) && isset( $groups_template->group->is_banned ) ) {
+		$retval = $groups_template->group->is_banned;
 
-		if ( !$user_id && isset( $group->is_banned ) )
-			return apply_filters( 'bp_group_is_user_banned', $group->is_banned );
-	}
+	// not in loop
+	} else {
+		// Default to not banned
+		$retval = 0;
 
-	if ( !$user_id )
-		$user_id = bp_loggedin_user_id();
+		if ( empty( $group ) ) {
+			$group = $groups_template->group;
+		}
+	
+		if ( empty( $user_id ) ) {
+			$user_id = bp_loggedin_user_id();
+		}
+
+		if ( ! empty( $user_id ) && ! empty( $group->id ) ) {
+			$retval = groups_is_user_banned( $user_id, $group->id );
+		}
+	}
 
-	return apply_filters( 'bp_group_is_user_banned', groups_is_user_banned( $user_id, $group->id ) );
+	return apply_filters( 'bp_group_is_user_banned', $retval );
 }
 
 function bp_group_accept_invite_link() {
Index: tests/phpunit/testcases/groups/template.php
===================================================================
--- tests/phpunit/testcases/groups/template.php
+++ tests/phpunit/testcases/groups/template.php
@@ -689,4 +689,73 @@
 			$this->assertEquals( $v, $requests_template->requests[0]->{$k} );
 		}
 	}
+
+	/**
+	 * @group bp_group_is_user_banned
+	 */
+	public function test_bp_group_is_user_banned_in_groups_loop() {
+		$u1 = $this->create_user();
+		$u2 = $this->create_user();
+		$g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
+		$g2 = $this->factory->group->create( array( 'creator_id' => $u2 ) );
+		groups_join_group( $g1, $u2 );
+		groups_join_group( $g2, $u2 );
+		groups_join_group( $g2, $u1 );
+
+		// Ban user 1 from group 2
+		// Fool the admin check
+		$old_user = get_current_user_id();
+		$this->set_current_user( $u2 );
+		buddypress()->is_item_admin = true;
+		groups_ban_member( $u1, $g2 );
+
+		// Start the groups loop
+		$this->set_current_user( $u1 );
+		if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group();
+			$found[] = bp_group_is_user_banned();
+		endwhile; endif;
+
+		// Assert
+		$expected = array( 0, 1 );
+		$this->assertEquals( $expected, $found );
+
+		// Clean up
+		$GLOBALS['groups_template'] = null;
+		$this->set_current_user( $old_user );
+	}
+
+	/**
+	 * @group bp_group_is_user_banned
+	 */
+	public function test_bp_group_is_user_banned_not_in_groups_loop() {
+		$u1 = $this->create_user();
+		$u2 = $this->create_user();
+		$g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
+		$g2 = $this->factory->group->create( array( 'creator_id' => $u2 ) );
+		groups_join_group( $g1, $u2 );
+		groups_join_group( $g2, $u2 );
+		groups_join_group( $g2, $u1 );
+
+		// Ban user 1 from group 2
+		// Fool the admin check
+		$old_user = get_current_user_id();
+		$this->set_current_user( $u2 );
+		buddypress()->is_item_admin = true;
+		groups_ban_member( $u1, $g2 );
+
+		// Do group ban checks
+		$group1 = new BP_Groups_Group( $g1 );
+		$group2 = new BP_Groups_Group( $g2 );
+
+		$found = array();
+		$found[] = bp_group_is_user_banned( $group1, $u1 );
+		$found[] = bp_group_is_user_banned( $group2, $u1 );
+
+		// Assert
+		$expected = array( 0, 1 );
+		$this->assertEquals( $expected, $found );
+
+		// Clean up
+		$this->set_current_user( $old_user );
+	}
 }
