‘user_register’ hook – need to distinguish if created from wp admin panel

Users are created in two ways in my application.

The registration form uses a gravity form hook to register the user and send to various api’s.

But when creating a user from the admin panel, we use the ‘user_register‘ hook.

This causes a conflict because in the gravity form procedure , when calling wp_insert_user(), it triggers the ‘user_register‘ hook , interrupting the script which isn’t finished saving the user to the api’s.

So I would have liked a hook which is only triggered when run from the admin panel.
Can this be accomplished?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You could use the user_register hook, then check if the user registration is happening from an admin interface with is_admin():

is_admin()

Determines whether the current request is for an administrative interface page.

https://developer.wordpress.org/reference/functions/is_admin/


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x