mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Allow plugins to hook into user preferences update process on the server (#21737)
This commit introduces a new `within_user_updater_transaction` event that's triggered inside the transaction that saves user updates in `UserUpdater`. Plugins can hook into the transaction using the event to include custom changes in the transaction. Callbacks for this event receive 2 arguments: 1. the user being saved 2. the changed attributes that are passed to `UserUpdater`. There's also new modifier in this commit called `users_controller_update_user_params` to allow plugins to allowlist custom params in the `UsersController` which eventually end up getting passed as attributes to the `UserUpdater` and the new `within_user_updater_transaction` event where they can be used to perform additional updates using the custom params. ----- New API is used in https://github.com/discourse/discourse-mailinglist-integration/pull/1.
This commit is contained in:
@@ -2015,7 +2015,13 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
deprecate_modify_user_params_method
|
||||
modify_user_params(result)
|
||||
result = modify_user_params(result)
|
||||
DiscoursePluginRegistry.apply_modifier(
|
||||
:users_controller_update_user_params,
|
||||
result,
|
||||
current_user,
|
||||
params,
|
||||
)
|
||||
end
|
||||
|
||||
# Plugins can use this to modify user parameters
|
||||
|
||||
Reference in New Issue
Block a user