Created
September 3, 2014 14:21
-
-
Save aschweigert/4d1a19ae3c71fd13f598 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wpmu_validate_user_signup','nd_validate_user_signup',10,3); | |
add_filter('signup_extra_fields','nd_extra_fields',10,1); | |
add_filter('add_signup_meta','nd_add_signup_meta'); | |
add_action('wpmu_activate_user','nd_wpmu_activate_user', 10, 3); | |
function nd_extra_fields ($result) { | |
$first_name = ( isset( $_POST['first_name'] ) ) ? $_POST['first_name']: ''; | |
$last_name = ( isset( $_POST['last_name'] ) ) ? $_POST['last_name']: ''; | |
$error_msgs = $result->errors; | |
?> | |
<p> | |
<label for="first_name">First Name<br /> | |
<?php if ( isset($error_msgs['first_name']) && $errmsg = $error_msgs['first_name'][0] ) { | |
echo ' <p class="error">'.$errmsg.'</p>'; | |
} | |
?> | |
<input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr(stripslashes($first_name)); ?>" /></label> | |
</p> | |
<p> | |
<label for="last_name">Last Name<br /> | |
<?php if ( isset($error_msgs['last_name']) && $errmsg = $error_msgs['last_name'][0] ) { | |
echo ' <p class="error">'.$errmsg.'</p>'; | |
} | |
?> | |
<input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr(stripslashes($last_name)); ?>" /></label> | |
</p> | |
<?php | |
} | |
function nd_validate_user_signup ($result) { | |
if ( empty( $_POST['first_name'] ) ) | |
$result['errors']->add( 'first_name', __('<strong>ERROR</strong>: You must include a first name.','largo') ); | |
if ( empty( $_POST['last_name'] ) ) | |
$result['errors']->add( 'last_name', __('<strong>ERROR</strong>: You must include a last name.','largo') ); | |
return $result; | |
} | |
function nd_add_signup_meta($meta) { | |
$data = $_POST['first_name']; | |
$my_meta = array('first_name' => $data); | |
$meta = array_merge($my_meta, $meta); | |
$data = $_POST['last_name']; | |
$my_meta = array('last_name' => $data); | |
$meta = array_merge($my_meta, $meta); | |
return $meta; | |
} | |
function nd_wpmu_activate_user($userid, $password, $meta) { | |
if ( !empty($meta['first_name'])) | |
update_user_meta($userid, "first_name",$meta['first_name']); | |
if ( !empty($meta['last_name'])) | |
update_user_meta($userid, "last_name",$meta['last_name']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment