2

Is there an add_filter where you can see/modify all the $_POST data submitted for a new user registration before the user is created?

Thanks

2 Answers 2

2

Well once I looked into it, it is quite simple. $_POST is global variable and contains all the POSTed data that was sent from the form.

For example, to email yourself all the posted data submitted in the form, you you could use something like this:

    function email_me_post_data() {
        global $_POST;
        $msg = print_r($_POST, true);
        mail('me@myemail.com', 'Example POST data', $msg);
    }
    add_action( 'user_register', 'email_me_post_data' );

Note that user_register action occurs AFTER the new user is created. Not sure you can get to the post data before user is created, although you could still modify data and re-save the changes.

1

You can use the register_post hook. Here is the list of hooks and filters that fire during user reg (in order that they are fired):

  1. register_post - used to handle post data from a user registration before the registration_errors filter is called or errors are returned
  2. registration_errors - filters the errors encountered when a new user is being registered.
  3. user_register - allows you to access data for a new user immediately after they are added to the database
2
  • register_post only passes login and email but not the rest of the data that was POSTed.
    – jsherk
    Jun 5, 2016 at 17:10
  • What else do you want to check? A custom field?
    – thebigtine
    Jun 5, 2016 at 17:21

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.