Support » Developing with WordPress » Firing hooks on user creation

  • oguruma

    (@oguruma)


    I need to fire a webhook when a user is created. I’m not sure which hook to use, though.

    I need to pass into the hook’s function some meta about the user such as their First Name, Last Name, email, and a custom meta field I created (their mobile number).

    user_register() seems to be the one I want, but the codex does say:

    “Not all user meta data has been stored in the database when this action is triggered. For example, nickname is in the database but first_name and last_name are not (as of v3.9.1). The password has already been encrypted when this action is triggered.”

    So, that leads me to believe that I might not be able to access all of the data I need on the newly created user….

    • This topic was modified 3 months ago by oguruma.
Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter oguruma

    (@oguruma)

    @bcworkz At this point, I think I almost might be better off just modifying the default WordPress registration form….

    Basically, all I really need is a way to capture a mobile or landline phone number in addition to normal registration data.

    That would make less reliant on the JetForm plugin, I suppose…

    Moderator bcworkz

    (@bcworkz)

    If you prefer. At least there are more people here who understand that process to help you with it. The source code is open to all to examine and test. This might help to that end:
    https://codex.wordpress.org/Customizing_the_Registration_Form

    You can also alter the page’s CSS to alter its appearance. For that matter, you could create your own form page still, as long as the field names stay the same and the form submits to the same place. The tricky part is getting the right nonce value to validate the form. It’s not so much the form we’re struggling with as much as what happens after submittal.

    Thread Starter oguruma

    (@oguruma)

    Another problem is that I want users to bypass email confirmation and immediately log in with their own account, which seems to be another can of worms….

    Moderator bcworkz

    (@bcworkz)

    Yes it does. Maybe the best approach would be to create a custom registration form and your own form submission handler. Create a new user from the submitted information with wp_create_user() or wp_insert_user().

    Without email confirmation, you’re prone to getting undesirable spammy users. And sometimes real users who are confused but there’s no way to contact them because their email on record is bogus.

    At least you’d have control over the entire process and know what hooks fire 🙂

Viewing 4 replies - 16 through 19 (of 19 total)
  • You must be logged in to reply to this topic.