• Resolved PxO Ink

    (@pxoink)


    Hi There,

    I’m not a stranger to WordPress, but I am not familiar with adding filters to core components, such as registration or email notification.

    My current challenge is to provide custom fields on the registration page, and to have those fields be handled via the update_user_meta() function. I would use an existing plugin like CIMY, however, I need to modify the HTML of these inputs directly and I need certain functions to trigger based upon $_POST values.

    I’m trying to add my plugin to run with the existing registration system (add_filter to wp_insert_user,) so that I don’t need to reinvent the wheel. I have absolutely no idea if I’m on the right track, and it’s definitely not working. What I have worked out, is that somewhere between the registration form and wp_insert_user, $userdata takes control of the $_POST variables. Any help would be appreciated.

    This is the concept of the code I’ve come up with:

    function update_this_field($userdata, $user_id) {
         if ( empty($userdata -> value_a) )
              return new WP_Error('empty_value_a', __('Cannot create a user with an empty value a.') );
    
         update_user_meta($user_id, 'value_a', $userdata -> value_a);
    }

    Additionally, I’d like to include these values in the registration email and I suspect I will need to make use of add_filter to do so. Any guidance here would also be appreciated.

Viewing 1 replies (of 1 total)
  • Thread Starter PxO Ink

    (@pxoink)

    Okay, to those who were wondering how to deal with the add_filter shenanigans:

    add_filter(‘user_register’, ‘my_function’, 10, 1);

    The argument is $user_id. YOU DO NOT NEED TO SUPPLY THIS. It’s automatic and/or magical. After that, you have to somehow get custom $_POST information to be visible (hint: use <?php $template->the_instance(); ?> after your ID name.)

Viewing 1 replies (of 1 total)
  • The topic ‘User registration/email notification filters’ is closed to new replies.