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()->on('users.beforeSaveUser', function(Event $event) {
// Only do this for existing users
if(!$event->params['isNewUser'])
{
// Get ID of user about to be saved
$userId = $event->params['user']->id;
// Look up existing user data
$existing = craft()->users->getUserById($userId);
// Why does this contain the NEW data?
Craft::dd($existing->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?