Create/Edit user without Email Adresse (9 posts)

  1. mullion
    Posted 3 years ago #


    I need to be able to create/edit user without email adresse.

    I tried to find how the wordpress core works. But it's kind of very complex to simply remove all the "required validation" for the email adress.

    Thank you


  2. bcworkz
    Posted 3 years ago #

    Email is an important part of user management. I suspect it would be very difficult to entirely remove it's requirement. However, I don't think it generally has to be a valid email, only of a valid form. Whether it really works doesn't normally matter. I've added several users to my test installation, which isn't even capable of sending e-mails. Obviously, the reset password and similar functions that require functional email do not work.

    Simply provide an email such as username@yourdomain.com. Won't matter if it doesn't receive mail. There's surely a way to even auto-populate the field regardless if a user provides one or not.

    But completely remove it's requirement? Good luck with that. ;)

  3. Raaj Trambadia
    Posted 3 years ago #

    Not possible. It's like your ID to enter the best club in town!

  4. Thomas Maier
    Posted 3 years ago #

    It is no problem when creating and updating a user programmatically with
    wp_create_user() and wp_update_user()
    but not with the forms.

  5. Thomas Maier
    Posted 3 years ago #

    I had a second look in the code and found a way to let you even udpate the user with the user edit form in the admin panel without the user having an email address or even deleting the email address:

    this code deleted the error message for empty emails from the error object and if there are no errors, the form is saved

    put this into functions.php or in your plugin

    add_action( 'user_profile_update_errors', 'remove_empty_email_error' );
    function remove_empty_email_error( $arg ) {
        if ( !empty( $arg->errors['empty_email'] ) ) unset( $arg->errors['empty_email'] );
  6. Sonja
    Posted 3 years ago #

    Danke @Webzunft

    This seems to work, but only on the update screen.

    It does not seem to change the behavior of the add new user screen.

    Anyone have any ideas?

  7. clickmac
    Posted 3 years ago #

    nice! thanks

  8. Thomas Maier
    Posted 3 years ago #

    strange, because it is basically the same function to create and edit users. I currently don't run the project I developed this for and so can't test it. Sorry.

  9. dagtuts
    Posted 3 years ago #

    This will work if you are comfortable with coding:

    You can simply create your own user creation page in the front end and use wp_create_user() function to insert them.
    Then use webzunft's code for them to edit their user afterward.

    I would add captcha and other checks to keep from getting spammed too badly also.

    @webzunft --> Thank you much for the code; its perfect for what I was looking to do.

Topic Closed

This topic has been closed to new replies.

About this Topic