Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which action hooks are triggered when new users are created/registered?

Tags:

wordpress

I often need to "do things" when new users are created in my Wordpress site. The only action hook that I know I can count on is user_register.

The problem is that I think it is triggered relatively early in the process of user creation, so often there is user information that is not available or other plugins make changes after my functions are called.

I've researched but had no luck, what resources explain the way WordPress creates users and which hooks fire when?

like image 897
emersonthis Avatar asked Sep 06 '12 19:09

emersonthis


People also ask

What are action hooks in WordPress?

Actions are one of the two types of Hooks. They provide a way for running a function at a specific point in the execution of WordPress Core, plugins, and themes. Callback functions for an Action do not return anything back to the calling Action hook. They are the counterpart to Filters.


1 Answers

In this case, the best documentation is the code itself.

The hook user_register is fired in /wp-includes/user.php#L1418 and no other useful action seem to be available there.

We got user_profile_update_errors in /wp-admin/includes/user.php, but not sure of its usability here.

The function wp_new_user_notification() called in the previous file is pluggable, meaning that you can override it and do your own stuff there. Maybe it's a good option.

like image 99
brasofilo Avatar answered Oct 02 '22 03:10

brasofilo