I am working on an existing plugin where we perform a modification to a
site_optionsfield whenever a user’s role changes.
Right now we are tracking this by hooking into
user_profile_update_errorshook will always catch edits to a user by firing at the end of the user update function, whether done on the user edit page or the profile page for a given user.
set_user_rolehook will catch user role changes done through the
wp-admin/users.phplisting page using the bulk role change drop down window.
The issue is that the
set_user_rolewill also occur shortly after the
user_profile_update_errorsdoes when editing a user via the edit page or profile page, resulting in our functionality being run twice when it only needs to run once in those cases.
This may just be a regression on our part; I think we were using
user_profile_update_errorsto look for any issues with the updating the user before calling our own functionality.
Is it safe to assume that we can just hook into
set_user_role, and that this is the only place where the codebase will have updated a user role? Or is there another hook I need to look for in case there is a different place where the user’s role may have been updated?
- You must be logged in to reply to this topic.