Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Berdir on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
The following hooks have been updated in the same way and only receive the updated $account entity. The original, unchanged $account can be accessed through $account->original.
- hook_user_presave()
- hook_user_insert()
- hook_user_update()
// Drupal 7
function mymodule_user_presave(&$edit, $account, $category) {
// Make sure that our form value 'mymodule_foo' is stored as
// 'mymodule_bar' in the 'data' (serialized) column.
if (isset($edit['mymodule_foo'])) {
$edit['data']['mymodule_bar'] = $edit['mymodule_foo'];
}
}
// Drupal 8
function mymodule_user_presave($account) {
// Make sure that our form value 'mymodule_foo' is stored as
// 'mymodule_bar' in the 'data' (serialized) column.
if (isset($account->mymodule_foo)) {
$account->data['mymodule_bar'] = $account->mymodule_foo;
}
}
Impacts:
Module developers