wafa_zitouna
wafa_zitouna

Reputation: 47

WordPress add user from backend without email adress

I would like to add users from Backend without an email address. How can I achieve that?

I want the set email address to not required.

I found a function to remove address email when updating user profile;

function delete_empty_email_error( $arg ) {
    if ( !empty( $arg->errors['empty_email'] ) ) unset( $arg->errors['empty_email'] );
    if(isset($wp_error->errors['email_exists'])){
        unset($wp_error->errors['email_exists']);
    }
}
add_action( 'user_profile_update_errors', 'delete_empty_email_error' );

I Think to add an action or a filter to skid empty error email? is it possible?

Upvotes: 0

Views: 5567

Answers (1)

wafa_zitouna
wafa_zitouna

Reputation: 47

Finally I find the answer, I hope it helps someone other

add_filter('registration_errors','dev_registration_errors');
function dev_registration_errors($errors){
    unset($errors->errors['empty_email']);
    }

    add_action('admin_footer','dev_admin_footer',1);
function dev_admin_footer(){
    ?>
    <script type="text/javascript">
        jQuery('label[for="email"] > span.description').hide();
        jQuery('#createuser input[name=email]').closest('tr').removeClass('form-required');
    </script>
    <?php
}

Upvotes: 1

Related Questions