I've got a function which is running on hook_ENTITY_TYPE_update for the user account, but I want to be able to compare against previous values that may have been on the user account, eg see if the user has changed their email address and be able to react to it.

I can see that if I run the debug on the $entity value that is part of the function that there is an 'original' item within the values array, is that the only way to retrieve the pre-edited data?

1 Answer 1


Yes, the data prior to the edit is stored in original, which will let you access all the methods of the user object but return values of its prior state.

So, for example, to check whether the email address has been changed:

$previous_email = $account->original->getEmail();

if ($previous_email !== $account->getEmail()) {
  • Nice one, I dunno why my IDE kept warning me that I couldn't call $account->original so I never tried running it, but it even says that it's how you get it from here - api.drupal.org/api/drupal/… May 11, 2022 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.