I seem to have a problem with a custom field on the register form (used in conjunction with WooCommerce)

    function my_account_send_form_post_data( ) {

        $email = $_POST["email"];
        $firstname = $_POST["billing_first_name"];
        $lastname = $_POST["billing_last_name"];

        $api = $this->get_api();
        if ( ! $api ) {
            return false;

        if ( isset( $_POST['mailchimp-subscribe'] ) && 'yes' == $_POST['mailchimp-subscribe'] ) {
            $list_id = $this->get_option( 'wc_mailchimp_list_id' );

            $double_optin = $this->get_option( 'wc_mailchimp_double_optin' ) == 'yes';

            $api->my_account_subscribe_to_list( $list_id, $firstname, $lastname, $email);

        return true;

     * Subscribe to Mailchimp via account registration on my-account page
     * @param  string      $list_id   
     * @param  string      $firstname 
     * @param  string      $lastname  
     * @param  string      $email

    public function my_account_subscribe_to_list( $list_id, $firstname, $lastname, $email) 

        $data = array(
            'id' => $list_id,
            'email' => array( 'email' => $email ),
            'merge_vars' => array(
                'FNAME' => $firstname,
                'LNAME' => $lastname,                   
            'double_optin' => false,
            'update_existing' => true,

        $response = $this->perform_request( '/lists/subscribe.json', $data );

        $response = wp_remote_retrieve_body( $response );
        echo print_r($response, true);
        if ( is_wp_error( $response ) ) {
            return false;

        $response = json_decode( $response, true );
        echo print_r($response, true);
        if ( isset( $response['status'] ) && 'error' ==  $response['status'] ) {
            return false;

        return true;

As you can see the my_account_subscribe_to_list handles the submission of the custom information and will print_r the response.

First attempt you try to register you will be registered to WordPress correctly but the custom data is never processed.

On second attempt registering an account using the same registration information as the first attempt. You will receive an error that the registration information is already in use (as suspected). But you will also receive the output of $response hence the custom field and data is being processed.


In the documentation for register_form is a mention of user_register under hooks which is used to:

This action hook allows you to access data for a new user immediately after they are added to the database. The user id is passed to hook as an argument.

Typically, this hook is used for saving additional user meta passed by custom registration forms.

changing register_form to user_register fixed the issue and let me do additional data handling when the registration is completing

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.