WordPress.org

Ready to get started?Download WordPress

Forums

Create/Edit user without Email Adresse (9 posts)

  1. mullion
    Member
    Posted 1 year ago #

    Hello,

    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

    Vincent

  2. bcworkz
    Member
    Posted 1 year 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. raajtram
    Member
    Posted 1 year ago #

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

  4. Thomas Maier
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

    nice! thanks

  8. Thomas Maier
    Member
    Posted 1 year ago #

    @summit
    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
    Member
    Posted 1 year 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