first name and last name on registration page
-
How can i put the First name and Last name fields onto the registration page?
-
I am currently working on a version of wp-signup.php that allows you to do this. It might be a day or two until I get it working as I am also trying to comment the hell out of it since its really not well documented.
The version I’m working on is for WordPress MU so I’m not sure if I could help. Let me know if you came across any solutions. Thanks!
Ok, so heres some stuff that I’ve been able to pull together using the WP-Invite Plugin and Force Registration Fields Plugin. As far as I can tell, WordPressMU’s action hooks are not very well documented, so I cant really explain everything thats going on. Eventually I will release this as a plugin, but its taking sometime since they cant get their act straight and document their own software. Here we go:
$fergcorp_forceRegistrationField_getOptions = get_option("fergcorp_forceRegistrationField");
The above gets the values stored in the database table: wp_1_options
The array returned from the database is:
a:1:{s:16:"additionalFields";a:2:{i:0;s:10:"first_name";i:1;s:9:"last_name";}}
add_action('signup_extra_fields', 'add_custom_registration_fields'); //adds custom fields to form, wordpressmu add_filter('wpmu_validate_user_signup', 'check_custom_fields',99,1); //checks custom fields to form, wordpressmu add_action('wpmu_activate_user', 'update_custom_fields',10,3); //updates and adds meta to database, wordpressmu
/* Add fields to the new user registration page that the user must fill out to register */ function add_custom_registration_fields($errors_mu){ global $fergcorp_forceRegistrationField_knownFields, $fergcorp_forceRegistrationField_getOptions, $errors; if($fergcorp_forceRegistrationField_getOptions["additionalFields"]){ foreach($fergcorp_forceRegistrationField_getOptions["additionalFields"] as $thisValue){ if(IS_WPMU) $error = $errors_mu->get_error_message('error-profile-field-'.$thisValue); ?> <p> <label><?php _e($fergcorp_forceRegistrationField_knownFields[$thisValue], 'fergcorp_forceRegistrationField') ?><br /> <?php if($error) echo '<p class="error">' . $error . '</p>'; ?> <input type="text" name="<?php echo $thisValue; ?>" id="<?php echo $thisValue; ?>" class="input" value="<?php echo attribute_escape(stripslashes($_POST[$thisValue])); ?>" size="25" tabindex="10" style="font-size: 20px; width: 97%; padding: 3px; margin-right: 6px;" /></label> </p> <?php } } }//end of add_custom_registration_fields /* Checks registration fields to make sure they are filled out. If they are not, an error is added */ function check_custom_fields($result) { $data['first-name'] = $_POST['first_name']; $data['last-name'] = $_POST['last_name']; if($data['first-name'] == '' && $_POST['stage'] == 'validate-user-signup') $result['errors']->add('error-profile-field-first_name', __('Error: You must enter your first name') ); if($data['last-name'] == '' && $_POST['stage'] == 'validate-user-signup') $result['errors']->add('error-profile-field-last_name', __('Error: You must enter your last name') ); return $result; }//end of check_custom_fields /* Add the additional metadata into the database after the user is created */ function update_custom_fields($user_id){ global $fergcorp_addField, $fergcorp_forceRegistrationField_getOptions; foreach($fergcorp_forceRegistrationField_getOptions["additionalFields"] as $thisValue){ update_usermeta( $user_id, $thisValue, $_POST[$thisValue]); } }
The problem im having is that, the first_name and last_name fields are still not being saved in the meta field and so when the user goes to register, their last name and first name wont appear in their profile.
If anyone has any references or just something that could help out, please support this topic. Thanks!
-alvin c.
Also, please do not recommend another plugin. I have tried using Register Plus and it does not work with wordpressmu 2.8.4.
Cimy is also great, but if I add a first name and last name then their will be duplicate fields since wordpressmu already comes with the first name and last name text fields.
Thanks, again!
I don’t know how I could help, but I do want a solution to this.
- The topic ‘first name and last name on registration page’ is closed to new replies.