I have a custom post type created for new users when they are added to a multisite environment using the wpmu_new_user hook, but I noticed that it was only fired on new user creation and not when an existing user is added to a site. Is there a hook that gets fired when both new or existing users are added to a site?
I have a custom post type created for new users when they are added to a multisite environment using the wpmu_new_user hook, but I noticed that it was only fired on new user creation and not when an existing user is added to a site. Is there a hook that gets fired when both new or existing users are added to a site?
Share Improve this question asked Aug 16, 2019 at 17:37 C0c0b33fC0c0b33f 606 bronze badges1 Answer
Reset to default 2There's one called added_existing_user
that fires immediately after adding an existing user.
Digging a little deeper, I find the function add_user_to_blog()
is used by both add_new_user_to_blog()
and add_existing_user_to_blog()
, and has an action hook named add_user_to_blog
. I'd look into using that last hook, if I wanted to ensure something happened when a user was added to a site, whether they were _new_
or _existing_
.