Entry element query missing user field data when user is suspended I have a channel in which each channel entry has a "users" field type that is limited to one user. My code below works fine when the user is not suspended, however if I suspend the user, the then $entry-&gt;user field is null rather than set to the array of one user like its normally set to.

Here is my code:

        // do criteria code to get pending transfers from patients channel
    $account = $userIdentity-&gt;getFieldValue('account')-&gt;first();
    $entryQuery = Entry::find()
        -&gt;section('networkAssets')
        -&gt;relatedTo(['targetElement' =&gt; $account, "field" =&gt; "account"])
        -&gt;orderBy('title asc');


    // Execute the query and get the results
    $entries = $entryQuery-&gt;anyStatus()-&gt;all();
    $assets = [];
    foreach($entries as $entry) {
        $user = $entry-&gt;user-&gt;one();
        $assets[] = [
            'id' =&gt; $entry-&gt;id,
            'slug' =&gt; $entry-&gt;slug,
            'title' =&gt; $entry-&gt;title,
            'email' =&gt; $user-&gt;email,
            'first_name' =&gt; $user-&gt;firstName,
            'last_name' =&gt; $user-&gt;lastName,
            'address1' =&gt; $entry-&gt;address1,
            'address2' =&gt; $entry-&gt;address2,
            'state_province' =&gt; $entry-&gt;stateProvince,
            'city' =&gt; $entry-&gt;city,
            'postal_code' =&gt; $entry-&gt;postalCode,
            'country' =&gt; $entry-&gt;country,
            'username' =&gt; $user-&gt;username,
            'password' =&gt; '',
            'status' =&gt; $user-&gt;getStatus(),
            'date_created' =&gt; $entry-&gt;dateCreated-&gt;format('m/d/Y') . "&lt;br&gt;" . $entry-&gt;dateCreated-&gt;format('H:i:s T'),
            'last_login' =&gt; $user-&gt;lastLoginDate ? $user-&gt;lastLoginDate-&gt;format('m/d/Y') . "&lt;br&gt;" . $user-&gt;lastLoginDate-&gt;format('H:i:s T') : 'Never',
            'phone' =&gt; $entry-&gt;phoneNumber
        ];
    }

    return $assets;


You can see in the foreach loop that Im getting the user from the looped entry result and storing it in a $user variable.

When I try to use $user I get a notice because $user is null.

How can I force this code to return the linked user in the user field even  when the user is suspended?
User queries by default will only return active users, not pending or suspended ones.

To include suspended users, change this line:



$user = $entry-&gt;user-&gt;one();


to this:

$user = $entry-&gt;user-&gt;status(['active', 'suspended'])-&gt;one();


Or if you want to include pending users as well (users who haven’t activated their account yet), you can do this:

$user = $entry-&gt;user-&gt;anyStatus()-&gt;one();