functions - Create new user without password

admin2025-06-03  2

For a specific use case, I need to add users only by username and email without having to input a password for them.

Right now if i try to leave the password field empty, it displays an error.

How can I create a new user without having to put password without modifying the core? is it possible to remove these fields from the user add form?

UPDATE: why do I need to do this?

referring to my other question here, the google authentication plugin checks (After successful google authentication) if the google email used is found in wordpress, for a given user.

So i just need to create users locally with their usernames and email only. I need to remove the password fields from the form and disable the built in login mechanism (but the latter is related to my other question mentioned above).

For a specific use case, I need to add users only by username and email without having to input a password for them.

Right now if i try to leave the password field empty, it displays an error.

How can I create a new user without having to put password without modifying the core? is it possible to remove these fields from the user add form?

UPDATE: why do I need to do this?

referring to my other question here, the google authentication plugin checks (After successful google authentication) if the google email used is found in wordpress, for a given user.

So i just need to create users locally with their usernames and email only. I need to remove the password fields from the form and disable the built in login mechanism (but the latter is related to my other question mentioned above).

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Mar 13, 2015 at 20:21 ccotccot 1493 silver badges12 bronze badges 6
  • Please explain why you want to do it that way. It could be that you are facing a XY Problem. – kaiser Commented Mar 13, 2015 at 20:23
  • @kaiser you are right, check my update. – ccot Commented Mar 13, 2015 at 20:26
  • How are you creating users? There are a few ways to create users: registration, wp-admin, network wp-admin, API. We setup our WP system to not use WP native auth either. – user42826 Commented Mar 13, 2015 at 20:33
  • @user42826 right now am adding them manually from wp-admin. However if you have a better method for this scenario am open to try it – ccot Commented Mar 13, 2015 at 20:47
  • WP multiste allows admins to create users without a password. We wrote our own plugin to add multiple users (no password required). There are other plugins out there that will do the same thing. – user42826 Commented Mar 14, 2015 at 0:32
 |  Show 1 more comment

1 Answer 1

Reset to default 5

Current versions of WP allow creation of a user without creating a password. Just leave password area blank, and verify no password if prompted.

But, best practice might be to create user with a random password, but not tell the user the password. Have them do the 'lost password' thing to set up their own password. That's what I do for my users. I don't have to tell them a password (sending one via plaintext in an email is not good), and they are responsible for creating a password they can remember.

(Old question without an answer, but guidance is appropriate for current versions and anyone that finds the question.)

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748933509a314941.html

最新回复(0)