Add a user to a userfield when there's a pending user on there I have this code to save a new user onto a userfield on another user:

    $employees   = $currentUser-&gt;employees-&gt;ids();
    $employees[] = $employee-&gt;id;
    $currentUser-&gt;getContent()-&gt;setAttributes(['employees' =&gt; $employees]);
    if (!craft()-&gt;users-&gt;saveUser($currentUser))
    {
        Craft::dd($currentUser-&gt;getErrors());
    }


Which works fine, however if there's a pending user in the employees field it's not returned in the ids() array. How do I get all user ids from the employees field, not just active users?

Edit: got it:

    $employees   = $currentUser-&gt;employees-&gt;status('*')-&gt;ids();
To mark this as answered, my solution was to use this code to get the current employee IDs regardless of status.

$employees   = $currentUser-&gt;employees-&gt;status('*')-&gt;ids();