I do know this has been ask a number of instances however I am searching for a greater method to do that. Presently, I’ve acquired it working however its not consumer pleasant as the shape will re-ask registrants to “please sort your e-mail handle” (although they’ve already achieved this). This may be seen on safetyworks.com/login.
Right here is the highest half of my code:
<?php
$current_email = isset($_POST['user_email']) ? $_POST['user_email'] : '';
$current_username = $current_email;
?>
<?php if ($this->should_print_form()) : ?>
<?php $this->print_form_header(); ?>
<div class="row clearfix">
<div class="col-sm-10 col-md-8 col-sm-offset-1 col-md-offset-2">
<div class="panel panel-primary panel-border prime">
<div class="panel-heading">
<span class="panel-title fs-lg"><i class="fa fa-edit"></i> <?php _e('Create an account', 'cuarlf'); ?></span>
</div>
<div class="panel-body">
<div class="form-group mb-lg">
<label for="user_email" class="control-label top-label"><?php _e('Electronic mail Handle', 'cuarlf'); ?></label>
<div class="row clearfix">
<div class="col-xs-12">
<span class="append-icon proper"><i class="field-icon fa fa-asterisk text-muted"></i></span>
<enter class="form-control" sort="electronic mail" title="user_email" id="user_email" worth="<?php echo esc_attr($current_email); ?>">
<enter class="form-control" sort="hidden" title="user_login" id="user_login" worth="<?php echo $current_username; ?>">
</div>
</div>
</div>
So is there a greater strategy to conceal username? I attempted utilizing Good WP Login however that wordpress nonetheless needs a username specified. I did additionally attempt a operate much like this however that failed.
After some digging, I discovered that WP-Buyer Space plugin has a operate that’s inflicting this situation.
public static operate register_new_user($user_login, $user_email)
{
world $wpdb;
$errors = new WP_Error();
$sanitized_user_login = sanitize_user($user_login);
$user_email = apply_filters('user_registration_email', $user_email);
// Test the username
if ($sanitized_user_login == '')
{
$errors->add('empty_username', __('Please enter a username.', 'cuarlf'));
}
elseif ( !validate_username($user_login))
{
$errors->add('invalid_username', __('Sorry. Please enter a username utilizing solely lowercase letters and numbers.', 'cuarlf'));
$sanitized_user_login = '';
}
elseif (username_exists($sanitized_user_login))
{
$errors->add('username_exists', __('This username is already registered. Please select one other one.', 'cuarlf'));
}
// Test the e-mail handle
if ($user_email == '')
{
$errors->add('empty_email', __('Please sort your electronic mail handle.', 'cuarlf'));
}
elseif ( !is_email($user_email))
{
$errors->add('invalid_email', __('The e-mail handle isn’t right.', 'cuarlf'));
$user_email = '';
}
elseif (email_exists($user_email))
{
$errors->add('email_exists', __('This electronic mail is already registered, please select one other one.', 'cuarlf'));
}
do_action('register_post', $sanitized_user_login, $user_email, $errors);
$errors = apply_filters('registration_errors', $errors, $sanitized_user_login, $user_email);
if ($errors->get_error_code())
{
return $errors;
}
$user_pass = wp_generate_password(12, false);
$user_id = wp_create_user($sanitized_user_login, $user_pass, $user_email);
if ( !$user_id)
{
$errors->add('registerfail',
sprintf(__('Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'cuarlf'), get_option('admin_email')));
return $errors;
}
update_user_option($user_id, 'default_password_nag', true, true); //Arrange the Password change nag.
// Generate one thing random for a key...
$activation_key = wp_generate_password(20, false);
do_action('retrieve_password_key', $user_login, $activation_key);
// Now insert the brand new md5 key into the db
$wpdb->replace($wpdb->customers, array('user_activation_key' => $activation_key), array('user_login' => $user_login));
// Ship notifications
$consumer = get_userdata($user_id);
self::new_user_notification_admin($consumer);
self::new_user_notification($consumer, $activation_key);
return $user_id;
}
The issue is why does the shape assume the e-mail handle is clean? I attempted to comply with Is it attainable to take away username area from the registration web page? If that’s the case, how? however that causes conflicts with WP-Buyer Space and will not work in a theme operate file as a result of that is learn after plugins.