3
votes
How can I ensure my_custom_module.install runs my_custom_module_update_8101()?
Update hooks are there to get the module into a known good state - the same state as when the module gets installed. It's for when you need to make changes to an already installed module, I'm not sure ...
2
votes
How can I ensure my_custom_module.install runs my_custom_module_update_8101()?
In the code shown in the question, Database::getConnection()->exec($sql) will cause an error, since the object returned by Database::getConnection() (a Connection object) doesn't have any exec() ...
1
vote
Accepted
How to get newly created user id in user_presave hook?
You can't get the user ID in a presave() hook for a new user because the ID isn't assigned until the user is saved.
So how do I run code that uses the user ID when saving a user, regardless of whether ...
1
vote
Accepted
How can I run a certain action when a taxonomy field value is removed or added?
Yes, hook_user_presave() is the way to go.
Here's an example for a standard field. You'll need to tweak this a bit for a taxonomy entity reference.
function MYMODULE_user_presave(UserBundle $user): ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
hooks × 26247 × 880
8 × 537
theming × 403
nodes × 279
forms × 279
views × 251
entities × 221
users × 185
routes × 114
6 × 86
blocks × 83
webforms × 66
commerce × 60
javascript × 52
database × 52
navigation × 45
taxonomy-terms × 44
ajax × 42
files × 41
media × 37
search × 34
emails × 33
9 × 31
caching × 28