`onBeforeSaveUser` - Access existing user data I'm trying to run a quick check to see if any of my user's data has changed before saving them. However, I'm running into a situation where I can only access the new data.

I can't tell if this is a bug, or simply a misunderstanding of how it works...

craft()-&gt;on('users.beforeSaveUser', function(Event $event) {

    // Only do this for existing users
    if(!$event-&gt;params['isNewUser'])
    {

        // Get ID of user about to be saved
        $userId = $event-&gt;params['user']-&gt;id;

        // Look up existing user data
        $existing = craft()-&gt;users-&gt;getUserById($userId);

        // Why does this contain the NEW data?
        Craft::dd($existing-&gt;myField);

    }

});


There may be a reasonable explanation as to why the pre-existing user data is not available. If that is the case, then how can I access the pre-existing data for this user?
Not totally sure, but I believe this may be because the UsersService actually caches UserModels fetched by getUserById() locally in a private class variable.

Instead of using getUserById(), try pulling the user with an ElementCriteriaModel:

$existing = craft()-&gt;elements-&gt;getCriteria(ElementType::User, array(
    'id' =&gt; $userId,
))-&gt;first();