Index: src/bp-blogs/classes/class-bp-blogs-blog.php
===================================================================
--- src/bp-blogs/classes/class-bp-blogs-blog.php
+++ src/bp-blogs/classes/class-bp-blogs-blog.php
@@ -48,7 +48,7 @@
 	 */
 	public function __construct( $id = null ) {
 		if ( !empty( $id ) ) {
-			$this->id = $id;
+			$this->id = (int) $id;
 			$this->populate();
 		}
 	}
@@ -63,8 +63,8 @@
 
 		$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
 
-		$this->user_id = $blog->user_id;
-		$this->blog_id = $blog->blog_id;
+		$this->user_id = (int) $blog->user_id;
+		$this->blog_id = (int) $blog->blog_id;
 	}
 
 	/**
Index: src/bp-core/classes/class-bp-user-query.php
===================================================================
--- src/bp-core/classes/class-bp-user-query.php
+++ src/bp-core/classes/class-bp-user-query.php
@@ -591,11 +591,14 @@
 		// Match up to the user ids from the main query.
 		foreach ( $this->user_ids as $key => $uid ) {
 			if ( isset( $r[ $uid ] ) ) {
+				$r[ $uid ]->ID = (int) $uid;
+				$r[ $uid ]->user_status = (int) $r[ $uid ]->user_status;
+
 				$this->results[ $uid ] = $r[ $uid ];
 
 				// The BP template functions expect an 'id'
 				// (as opposed to 'ID') property.
-				$this->results[ $uid ]->id = $uid;
+				$this->results[ $uid ]->id = (int) $uid;
 
 			// Remove user ID from original user_ids property.
 			} else {
Index: src/bp-groups/classes/class-bp-groups-group.php
===================================================================
--- src/bp-groups/classes/class-bp-groups-group.php
+++ src/bp-groups/classes/class-bp-groups-group.php
@@ -208,13 +208,13 @@
 		}
 
 		// Group found so setup the object variables.
-		$this->id           = $group->id;
-		$this->creator_id   = $group->creator_id;
+		$this->id           = (int) $group->id;
+		$this->creator_id   = (int) $group->creator_id;
 		$this->name         = stripslashes( $group->name );
 		$this->slug         = $group->slug;
 		$this->description  = stripslashes( $group->description );
 		$this->status       = $group->status;
-		$this->enable_forum = $group->enable_forum;
+		$this->enable_forum = (int) $group->enable_forum;
 		$this->date_created = $group->date_created;
 
 		// Are we getting extra group data?
@@ -231,6 +231,10 @@
 
 			// Add admins and moderators to their respective arrays.
 			foreach ( (array) $admin_mods as $user ) {
+				$user->user_id  = (int) $user->user_id;
+				$user->is_admin = (int) $user->is_admin;
+				$user->is_mod   = (int) $user->is_mod;
+
 				if ( !empty( $user->is_admin ) ) {
 					$this->admins[] = $user;
 				} else {
@@ -241,7 +245,7 @@
 			// Set up some specific group vars from meta. Excluded
 			// from the bp_groups cache because it's cached independently.
 			$this->last_activity      = groups_get_groupmeta( $this->id, 'last_activity' );
-			$this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' );
+			$this->total_member_count = (int) groups_get_groupmeta( $this->id, 'total_member_count' );
 
 			// Set user-specific data.
 			$user_id          = bp_loggedin_user_id();
Index: src/bp-groups/classes/class-bp-groups-member.php
===================================================================
--- src/bp-groups/classes/class-bp-groups-member.php
+++ src/bp-groups/classes/class-bp-groups-member.php
@@ -185,18 +185,18 @@
 		$member = $wpdb->get_row($sql);
 
 		if ( !empty( $member ) ) {
-			$this->id            = $member->id;
-			$this->group_id      = $member->group_id;
-			$this->user_id       = $member->user_id;
-			$this->inviter_id    = $member->inviter_id;
-			$this->is_admin      = $member->is_admin;
-			$this->is_mod        = $member->is_mod;
-			$this->is_banned     = $member->is_banned;
+			$this->id            = (int) $member->id;
+			$this->group_id      = (int) $member->group_id;
+			$this->user_id       = (int) $member->user_id;
+			$this->inviter_id    = (int) $member->inviter_id;
+			$this->is_admin      = (int) $member->is_admin;
+			$this->is_mod        = (int) $member->is_mod;
+			$this->is_banned     = (int) $member->is_banned;
 			$this->user_title    = $member->user_title;
 			$this->date_modified = $member->date_modified;
-			$this->is_confirmed  = $member->is_confirmed;
+			$this->is_confirmed  = (int) $member->is_confirmed;
 			$this->comments      = $member->comments;
-			$this->invite_sent   = $member->invite_sent;
+			$this->invite_sent   = (int) $member->invite_sent;
 
 			$this->user = new BP_Core_User( $this->user_id );
 		}
Index: src/bp-messages/classes/class-bp-messages-message.php
===================================================================
--- src/bp-messages/classes/class-bp-messages-message.php
+++ src/bp-messages/classes/class-bp-messages-message.php
@@ -88,9 +88,9 @@
 		$bp = buddypress();
 
 		if ( $message = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $id ) ) ) {
-			$this->id        = $message->id;
-			$this->thread_id = $message->thread_id;
-			$this->sender_id = $message->sender_id;
+			$this->id        = (int) $message->id;
+			$this->thread_id = (int) $message->thread_id;
+			$this->sender_id = (int) $message->sender_id;
 			$this->subject   = $message->subject;
 			$this->message   = $message->message;
 			$this->date_sent = $message->date_sent;
Index: src/bp-messages/classes/class-bp-messages-notice.php
===================================================================
--- src/bp-messages/classes/class-bp-messages-notice.php
+++ src/bp-messages/classes/class-bp-messages-notice.php
@@ -62,7 +62,7 @@
 	 */
 	public function __construct( $id = null ) {
 		if ( $id ) {
-			$this->id = $id;
+			$this->id = (int) $id;
 			$this->populate();
 		}
 	}
@@ -85,7 +85,7 @@
 			$this->subject   = $notice->subject;
 			$this->message   = $notice->message;
 			$this->date_sent = $notice->date_sent;
-			$this->is_active = $notice->is_active;
+			$this->is_active = (int) $notice->is_active;
 		}
 	}
 
Index: src/bp-messages/classes/class-bp-messages-thread.php
===================================================================
--- src/bp-messages/classes/class-bp-messages-thread.php
+++ src/bp-messages/classes/class-bp-messages-thread.php
@@ -166,14 +166,14 @@
 		}
 
 		$last_message_index         = count( $this->messages ) - 1;
-		$this->last_message_id      = $this->messages[ $last_message_index ]->id;
+		$this->last_message_id      = (int) $this->messages[ $last_message_index ]->id;
 		$this->last_message_date    = $this->messages[ $last_message_index ]->date_sent;
-		$this->last_sender_id       = $this->messages[ $last_message_index ]->sender_id;
+		$this->last_sender_id       = (int) $this->messages[ $last_message_index ]->sender_id;
 		$this->last_message_subject = $this->messages[ $last_message_index ]->subject;
 		$this->last_message_content = $this->messages[ $last_message_index ]->message;
 
 		foreach ( (array) $this->messages as $key => $message ) {
-			$this->sender_ids[ $message->sender_id ] = $message->sender_id;
+			$this->sender_ids[ $message->sender_id ] = (int) $message->sender_id;
 		}
 
 		// Fetch the recipients.
@@ -181,7 +181,7 @@
 
 		// Get the unread count for the logged in user.
 		if ( isset( $this->recipients[ $r['user_id'] ] ) ) {
-			$this->unread_count = $this->recipients[ $r['user_id'] ]->unread_count;
+			$this->unread_count = (int) $this->recipients[ $r['user_id'] ]->unread_count;
 		}
 
 		// Grab all message meta.
Index: src/bp-notifications/classes/class-bp-notifications-notification.php
===================================================================
--- src/bp-notifications/classes/class-bp-notifications-notification.php
+++ src/bp-notifications/classes/class-bp-notifications-notification.php
@@ -97,7 +97,7 @@
 	 */
 	public function __construct( $id = 0 ) {
 		if ( ! empty( $id ) ) {
-			$this->id = $id;
+			$this->id = (int) $id;
 			$this->populate();
 		}
 	}
@@ -188,13 +188,13 @@
 
 		// Setup the notification data.
 		if ( ! empty( $notification ) && ! is_wp_error( $notification ) ) {
-			$this->item_id           = $notification->item_id;
-			$this->secondary_item_id = $notification->secondary_item_id;
-			$this->user_id           = $notification->user_id;
+			$this->item_id           = (int) $notification->item_id;
+			$this->secondary_item_id = (int) $notification->secondary_item_id;
+			$this->user_id           = (int) $notification->user_id;
 			$this->component_name    = $notification->component_name;
 			$this->component_action  = $notification->component_action;
 			$this->date_notified     = $notification->date_notified;
-			$this->is_new            = $notification->is_new;
+			$this->is_new            = (int) $notification->is_new;
 		}
 	}
 
Index: src/bp-xprofile/classes/class-bp-xprofile-field.php
===================================================================
--- src/bp-xprofile/classes/class-bp-xprofile-field.php
+++ src/bp-xprofile/classes/class-bp-xprofile-field.php
@@ -260,10 +260,21 @@
 			$args = (array) $args;
 		}
 
+		$int_fields = array(
+			'id', 'is_required', 'group_id', 'parent_id', 'is_default_option',
+			'field_order', 'option_order', 'can_delete'
+		);
+
 		foreach ( $args as $k => $v ) {
 			if ( 'name' === $k || 'description' === $k ) {
 				$v = stripslashes( $v );
 			}
+
+			// Cast numeric strings as integers.
+			if ( true === in_array( $k, $int_fields ) ) {
+				$v = (int) $v;
+			}
+
 			$this->{$k} = $v;
 		}
 
Index: src/bp-xprofile/classes/class-bp-xprofile-group.php
===================================================================
--- src/bp-xprofile/classes/class-bp-xprofile-group.php
+++ src/bp-xprofile/classes/class-bp-xprofile-group.php
@@ -103,11 +103,11 @@
 		$group = reset( $group );
 
 		// Set object properties.
-		$this->id          = $group->id;
+		$this->id          = (int) $group->id;
 		$this->name        = $group->name;
 		$this->description = $group->description;
-		$this->can_delete  = $group->can_delete;
-		$this->group_order = $group->group_order;
+		$this->can_delete  = (int) $group->can_delete;
+		$this->group_order = (int) $group->group_order;
 	}
 
 	/**
@@ -466,6 +466,9 @@
 
 		// Merge the field array back in with the group array.
 		foreach( (array) $groups as $group ) {
+			$group->id          = (int) $group->id;
+			$group->group_order = (int) $group->group_order;
+			$group->can_delete  = (int) $group->can_delete;
 
 			// Indexes may have been shifted after previous deletions, so we get a
 			// fresh one each time through the loop.
Index: src/bp-xprofile/classes/class-bp-xprofile-profiledata.php
===================================================================
--- src/bp-xprofile/classes/class-bp-xprofile-profiledata.php
+++ src/bp-xprofile/classes/class-bp-xprofile-profiledata.php
@@ -88,16 +88,16 @@
 		}
 
 		if ( $profiledata ) {
-			$this->id           = $profiledata->id;
-			$this->user_id      = $profiledata->user_id;
-			$this->field_id     = $profiledata->field_id;
+			$this->id           = (int) $profiledata->id;
+			$this->user_id      = (int) $profiledata->user_id;
+			$this->field_id     = (int) $profiledata->field_id;
 			$this->value        = stripslashes( $profiledata->value );
 			$this->last_updated = $profiledata->last_updated;
 
 		} else {
 			// When no row is found, we'll need to set these properties manually.
-			$this->field_id	    = $field_id;
-			$this->user_id	    = $user_id;
+			$this->field_id	    = (int) $field_id;
+			$this->user_id	    = (int) $user_id;
 		}
 	}
 
