The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Add Custom Field to Register Form
Posted by: MC | November 1, 2010 @ 10:05am
PHP Code
[
Download
]
add_action('register_form','show_first_name_field'); add_action('register_post','check_fields',10,3); add_action('user_register', 'register_extra_fields'); function show_first_name_field(){ ?> <p> <label>First Name<br/> <input id="user_email" type="text" size="25? value="<?php echo $_POST['first']; ?>" name="first"/> </label> </p> <p> <label>Last Name<br/> <input id="user_email" type="text" size="25? value="<?php echo $_POST['last']; ?>" name="last"/> </label> </p> <?php } function check_fields($login, $email, $errors) { global $firstname, $lastname; if ($_POST['first'] == "") { $errors->add('empty_realname', "<strong>ERROR</strong>: Please enter a First Name"); } else { $firstname = $_POST['first']; } if ($_POST['last'] == "") { $errors->add('empty_realname', "<strong>ERROR</strong>: Please enter a Last Name"); } else { $firstname = $_POST['last']; } } function register_extra_fields($user_id, $password="", $meta=array()) { $userdata = array(); $userdata['ID'] = $user_id; $userdata['first_name'] = $_POST['first']; $userdata['last_name'] = $_POST['last']; wp_update_user($userdata); }
Syntax Highlighting
[
Open in new window
]
Author Comments
For Wordpress - to add first and last name to registration form.
Rating
4.38 / 8
50 Votes
http://codebin.yi.org/929
page generated in 0.01 seconds