0

I have a wordpress site and I have an external database I need to keep updated with the user information.

Whenever a user is created, updated, or otherwise modified by something like an admin, I need to update the other database. I thought there would be one or two hooks I would need to hook into (user created + user updated), but now I see that there are more than just those two.

user_register
profile_update
edit_user_profile_update

Are there any that I am missing? Which hooks do I need to get the job done? Does anyone have any advice to code this up?

URLs: https://codex.wordpress.org/Plugin_API/Action_Reference/user_register https://codex.wordpress.org/Plugin_API/Action_Reference/profile_update https://codex.wordpress.org/Plugin_API/Action_Reference/edit_user_profile_update

1

Those first 2 actions you linked to from the codex, user_register and profile_update should be exactly what you need.

user_register runs right after a user has successfully registered and gives you access to their $user_id which you can use to retrieve any user data you need, like name, email, etc.

add_action( 'user_register', 'wse_custom_register_action', 10, 1 );
function wse_custom_register_action( $user_id ) {
    // send data to your external db/API
}

profile_update works exactly the same way, and gives you access to both the old user data and the new, updated user data.

I don't believe you would need edit_user_profile_update in this instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.