Answer the question
In order to leave comments, you need to log in
How to create your own registration page without entering a login?
We have the simplest bzer registration page on WP:
<form id="registerform" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
<p>
<label for="user_login">
Имя пользователя<br>
<input type="text" name="user_login" id="user_login" class="input" value="" size="20" style="">
</label>
</p>
<p>
<label for="user_email">
E-mail<br>
<input type="email" name="user_email" id="user_email" class="input" value="" size="25">
</label>
</p>
<p id="reg_passmail">Подтверждение регистрации будет отправлено на ваш e-mail.</p>
<br class="clear">
<input type="hidden" name="redirect_to" value="">
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Регистрация"></p>
</form>
Answer the question
In order to leave comments, you need to log in
The beauty of WP is that the network has an answer to almost every Wishlist, you need to google in English ...
I did this:
Step-1: Hide the registration field
add_action('login_head', function(){
?>
<style>
#registerform > p:first-child{
display:none;
}
</style>
<script type="text/javascript" src="<?php echo site_url('/wp-includes/js/jquery/jquery.js'); ?>"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
$('#registerform > p:first-child').css('display', 'none');
});
</script>
<?php
});
//Remove error for username, only show error for email only.
add_filter('registration_errors', function($wp_error, $sanitized_user_login, $user_email){
if(isset($wp_error->errors['empty_username'])){
unset($wp_error->errors['empty_username']);
}
if(isset($wp_error->errors['username_exists'])){
unset($wp_error->errors['username_exists']);
}
return $wp_error;
}, 10, 3);
add_action('login_form_register', function(){
if(!isset($_POST['user_login']) && isset($_POST['user_email']) && !empty($_POST['user_email'])){
$_POST['user_login'] = $_POST['user_email'];
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question