[wp-trac] [WordPress Trac] #63770: WordPress wp_insert_user() throws warning when password is not provided

WordPress Trac noreply at wordpress.org
Fri Aug 1 03:09:13 UTC 2025


#63770: WordPress wp_insert_user() throws warning when password is not provided
-------------------------------------+-------------------------------
 Reporter:  sheldorofazeroth         |       Owner:  sheldorofazeroth
     Type:  defect (bug)             |      Status:  assigned
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Login and Registration   |     Version:  trunk
 Severity:  normal                   |  Resolution:
 Keywords:  has-test-info has-patch  |     Focuses:  coding-standards
-------------------------------------+-------------------------------
Changes (by sheldorofazeroth):

 * focuses:  docs => coding-standards


Comment:

 Replying to [comment:12 peterwilsoncc]:
 > I agree with @dd32 that throwing a warning in this instance is correct.
 The error can only be hit when developers call the function incorrectly.
 >
 > I think the fix for this is to improve the documentation for the
 function to note which items are required and which items are optional in
 the `$userdata` docblock.
 >
 @peterwilsoncc, If a password is required and not provided, user creation
 should be prevented. The function should return a clear and structured
 error object or message, rather than merely issuing a warning. Throwing
 warnings in such cases is not a good practice.

 If the password is marked as required in the function's documentation,
 then the function should enforce this by blocking user creation when the
 password is not provided. In such cases, it should return a clear and
 structured error object. Alternatively, if we choose not to enforce it
 strictly, we should at least implement a proper check and handle it
 gracefully instead of relying on a warning.

 Let me know what you think?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63770#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list