Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter sudopeople

    (@sudopeople)

    Well, that didn’t last long. I found and wrote some code after a bit more Googling.

    /*
     * Add Events Manager Phone field to registration page
     *
     */
    // This function shows the form fiend on registration page
    add_action('register_form','show_event_phone_field');
    
    // This is a check to see if you want to make a field required
    add_action('register_post','check_fields',10,3);
    
    // This inserts the data
    add_action('user_register', 'register_extra_fields');
    
    // This is the forms The Two forms that will be added to the wp register page
    function show_event_phone_field(){
    ?>
    <p>
    <label>Phone Number<br />
    <input id="dbem_phone" class="input" type="text" tabindex="20" size="25" value="<?php echo $_POST['dbem_phone']; ?>" name="dbem_phone"/>
    </label>
    </p>
    <?php
    }
    
    // This function checks to see if they didn't enter phone
    // If no phone: display Error
    function check_fields($login, $email, $errors) {
            global $phone;
            if ($_POST['dbem_phone'] == '') {
                    $errors->add('empty_realname', "<strong>ERROR</strong>: Please Enter Phone Number");
            } else {
                    $phone = $_POST['dbem_phone'];
            }
    }
    
    // This is where the magiv happens
    function register_extra_fields($user_id, $password="", $meta=array())  {
    
    // Gotta put all the info into an array
    $userdata = array();
    $userdata['ID'] = $user_id;
    
    // First name
    $userdata['dbem_phone'] = $_POST['dbem_phone'];
    
    // Enters into DB
    wp_update_user($userdata);
    
    // This is for custom meta data "gender" is the custom key and M is the value
    // update_usermeta($user_id, 'gender','M');
    
    }
    ?>

    Based on code found here: http://wordpress.org/support/topic/howto-custom-registration-fields?replies=6

    Enjoy!

    Thread Starter sudopeople

    (@sudopeople)

    FYI, it works rather nicely!

    …marking as resolved…move along.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    good solution, thx for sharing

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WordPress Registration Events Manager Phone’ is closed to new replies.