diff --git a/src/wp-includes/class-wp-user.php b/src/wp-includes/class-wp-user.php
index 6c2f3c1..a9d7f21 100644
--- a/src/wp-includes/class-wp-user.php
+++ b/src/wp-includes/class-wp-user.php
@@ -64,6 +64,14 @@ class WP_User implements JsonSerializable {
        public $filter = null;
        public $site_id = 0;

+       /**
+        * Whether the user object was initialized in short mode.
+        *
+        * @since 7.0.0
+        * @var bool
+        */
+       protected $short_init = false;
+
        /**
         * Constructor.
         */
@@ -82,6 +90,10 @@ class WP_User implements JsonSerializable {

                if ( is_array( $args ) && ! empty( $args['short_init'] ) ) {
                        $this->short_init = true;
+                       $this->roles     = array();
+                       $this->caps      = array();
+                       $this->allcaps   = array();
                }

                if ( is_object( $id ) ) {
@@ -135,6 +147,10 @@ class WP_User implements JsonSerializable {
                $this->ID = (int) $this->data->ID;

                if ( $this->short_init ) {
+                       // Defer loading of caps and roles.
                        return;
                }

                $this->for_site();
@@ -159,6 +175,10 @@ class WP_User implements JsonSerializable {

        public function for_site( $site_id = '' ) {
+               if ( $this->short_init ) {
+                       return;
+               }
+
                if ( empty( $site_id ) ) {
                        $site_id = get_current_blog_id();
                }
@@ -214,6 +234,18 @@ class WP_User implements JsonSerializable {
        }

+       /**
+        * Lazily load capability data when accessed.
+        */
+       protected function load_capability_data() {
+               if ( ! empty( $this->allcaps ) ) {
+                       return;
+               }
+
+               $this->short_init = false;
+               $this->for_site();
+       }
+
        public function get_role_caps() {
                global $wp_roles;

@@ -356,6 +388,7 @@ class WP_User implements JsonSerializable {
         */
        public function has_cap( $cap ) {
+               $this->load_capability_data();
                $cap = map_meta_cap( $cap, $this->ID );
                $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $cap, array() );
@@ -553,6 +586,24 @@ class WP_User implements JsonSerializable {
                return $this->data;
        }

+       /**
+        * Ensure caps are available during JSON encoding.
+        */
+       public function jsonSerialize() {
+               $this->load_capability_data();
+
+               return array(
+                       'ID'      => $this->ID,
+                       'roles'   => $this->roles,
+                       'caps'    => $this->caps,
+                       'allcaps' => $this->allcaps,
+                       'data'    => $this->data,
+               );
+       }
+
+       public function __serialize() {
+               $this->load_capability_data();
+               return get_object_vars( $this );
+       }
 }
