I am making a customized registration type which works utilizing username and electronic mail inputs, however after I embody First and Final title fields it will not let me register.
Right here is the shape:
<type id="_wb_register" motion="<?php echo home_url(); ?>" methodology="submit">
<p>
<label for="_wb_register_username"><?php _e('Username:', 'wb'); ?></label>
<enter sort="textual content" title="username" id="_wb_register_username" />
</p>
<p>
<label for="_wb_register_user_first_name"><?php _e('First Title:', 'wb'); ?></label>
<enter sort="textual content" title="user_first_name" id="_wb_register_user_first_name" worth="<?php echo esc_attr( wp_unslash( $first_name ) ); ?>" />
</p>
<p>
<label for="_wb_register_user_last_name"><?php _e('Final Title:', 'wb'); ?></label>
<enter sort="textual content" title="user_last_name" id="_wb_register_user_last_name" worth="<?php echo esc_attr( wp_unslash( $last_name ) ); ?>" />
</p>
<p>
<label for="_wb_register_email"><?php _e('E-mail:', 'wb'); ?></label>
<enter sort="electronic mail" title="electronic mail" id="_wb_register_email" />
</p>
<div class="padding" type="top: 5px;"></div>
<?php do_action('wb_user_panel_registration_form_bottom'); ?>
<p><enter sort="submit" worth="<?php _e('Signal Up', 'wb'); ?>" class="button-primary" /></p>
</type>
And right here is the perform used to create the consumer upon ending the registration type:
add_action('wp_ajax__wb_register', '_wb_register_function');
add_action('wp_ajax_nopriv__wb_register', '_wb_register_function');
perform _wb_register_function() {
$return = array();
$return['error'] = false;
$return['message'] = array();
//// VERIFIES NONCE
$nonce = isset($_POST['nonce']) ? trim($_POST['nonce']) : '';
if(!wp_verify_nonce($nonce, 'wb-register-nonce'))
die('Busted!');
//// VERIFIES CREDENTIALS
$username = isset($_POST['username']) ? trim($_POST['username']) : '';
$first_name = isset($_POST['user_first_name']) ? trim($_POST['user_first_name']) : '';
$last_name = isset($_POST['user_last_name']) ? trim($_POST['user_last_name']) : '';
$electronic mail = isset($_POST['email']) ? trim($_POST['email']) : '';
//// MAKES SURE USER HAS FILLED USERNAME AND EMAIL
if($electronic mail == '' || !is_email($electronic mail)) { $return['error'] = true; $return['message'] = __('Please sort in a sound electronic mail handle.', 'wb'); }
if($last_name == '') { $return['error'] = true; $return['message'] = __('Please enter your final title.', 'wb'); }
if($first_name == '') { $return['error'] = true; $return['message'] = __('Please enter your first title.', 'wb'); }
if($username == '') { $return['error'] = true; $return['message'] = __('Please select an username.', 'wb'); }
///// IF USER HAS FILLED USER, PASS, FIRST AND LAST
if($return['error'] == false) {
$return_registration = _wb_process_user_registration($return, $electronic mail, $username, $first_name, $last_name);
$return = $return_registration;
}
echo json_encode($return);
exit;
}
//////////////////////////////////////////////////////////////////////
///// THIS FUNCTION PROCESSES REGISTRATIONS
//////////////////////////////////////////////////////////////////////
perform _wb_process_user_registration($return, $electronic mail, $username, $first_name, $last_name) {
//// CHECKS IF USERNAME EXISTS
$consumer = new WP_User('', $username);
if(!$user->exists()) {
//// CHECK FOR USERNAMES EMAIL
$consumer = get_user_by('electronic mail', $electronic mail);
if(!$consumer) {
$password = wp_generate_password();
//// NOW WE CAN FINALLY REGISTER THE USER
$args = array(
'user_login' => esc_attr($username),
'first_name' => $first_name,
'last_name' => $last_name,
'user_email' => $electronic mail,
'user_pass' => $password,
'position' => 'submitter',
);
//// CREATES THE USER
$consumer = wp_insert_user($args);
if(!is_object($consumer)) {
//// MAKES SURE HE CAN"T SEE THE ADMIN BAR
update_user_meta($consumer, 'show_admin_bar_front', 'false');
$consumer = new WP_User($consumer);
After I submit the registration type it provides me the ‘Please enter your first title.’ error, so at the very least that a part of the perform is working. I do not perceive why the First and Final names will not be being registered when the Username and E-mail work simply tremendous. Is there one thing I am lacking?