Support » Everything else WordPress » How can I make Email field not-required?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @nabidanzum I hope you are well

    Try to put the next code in your functions.php

    // 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
    }
    • This reply was modified 6 months, 2 weeks ago by Andres Vega.
    Thread Starter Nabid Anzum

    (@nabidanzum)

    @gydoar

    Thanks a lot. It works perfectly.

    Perfect! You don’t forget mark like a solved the topic.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I make Email field not-required?’ is closed to new replies.