The topic of wpexpelor is about WordPress add user without email. One of the common problems, when you plan to register a new user on your WordPress site as a customer (or even other roles!), is that you need an email! Here, we are going to learn how you can remove this requirement. Creating users without Email in WordPress is easy! Just follow the steps:
- Open the WordPress admin panel.
- From the display section, open the edit theme section.
- Open the “functions.php” file to edit in this step. (It is recommended to use a Child theme for consistent results.)
- Add the following code at the end of the “functions.php” file and click on save.
// This will suppress empty email errors when submitting the user form
add_action('user_profile_update_errors', 'my_user_profile_update_errors', 10, 3 );
function my_user_profile_update_errors($errors, $update, $user) {
$errors->remove('empty_email');
}
// This will remove javascript required validation for email input
// It will also remove the '(required)' text in the label
// Works for new user, user profile and edit user forms
add_action('user_new_form', 'my_user_new_form', 10, 1);
add_action('show_user_profile', 'my_user_new_form', 10, 1);
add_action('edit_user_profile', 'my_user_new_form', 10, 1);
function my_user_new_form($form_type) {
?>
<script type="text/javascript">
jQuery('#email').closest('tr').removeClass('form-required').find('.description').remove();
// Uncheck send new user email option by default
<?php if (isset($form_type) && $form_type === 'add-new-user') : ?>
jQuery('#send_user_notification').removeAttr('checked');
<?php endif; ?>
</script>
<?php
}
Now, just go to the user section and add a new user.
You can create new users by just entering the username and password.
You don’t need an email to register a user. WooCommerce user registration form without email has the same procedure.
Note: By deleting the email field, users will not be able to restore their account by email when they forget the password.
Best. Please comment on any questions below.
2 Comments
It’s remarkable to pay a quick visit this
web page and reading the views of all mates concerning this paragraph, while I am also eager of getting know-how.
I am sure this piece of writing has touched all the
internet people, its really really pleasant post on building up new
weblog.