[wp-hackers] action on change of role only

Andrew Nacin wp at andrewnacin.com
Wed Jul 14 01:34:33 UTC 2010


On Wed, Jul 14, 2010 at 4:36 AM, Andrew Gray <andrew at graymerica.com> wrote:

> Does anyone have any idea how to get the previous role to see if it changed
> before the action in the hook or if there is another action I should attach
> to,
>

On Tue, Jul 13, 2010 at 9:23 PM, Sergey Biryukov <sergeybiryukov.ru@
gmail.com> wrote:

> add_action('update_user_meta', 'change_role_notify', 10, 4);


I would not hook into update_user_meta... Let's say we decided to change how
we stored user roles in the future. You should always use the hooks
intended, or your plugin may break in the future if the storage schema
changes. (And it probably will in the next two releases.)

So, here's my suggestion --

1. When creating a pending user, drop in a meta key/value pair you can check
for later. Then on on role change, look for the meta key. If it exists,
you'll know the user was pending. (Then delete it.)

2. Create a ticket at http://core.trac.wordpress.org and suggest that the
old $this->roles is set to a variable before being unset, and then passed to
the action. You are welcome to assign the ticket to me and I will take care
of it for 3.1. You can also submit a patch if you want (preferred!).

Also, without starting a tangental discussion, can we get back to
bottom-posting? Top-posting replies is not proper mailing list etiquette.


More information about the wp-hackers mailing list