WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 3 months ago

#21910 new enhancement

wpmu_create_user() standardization

Reported by: ryanduff Owned by:
Milestone: Future Release Priority: normal
Severity: minor Version: 3.0
Component: Users Keywords: needs-patch
Focuses: multisite Cc:

Description

There seems to be some inconsistencies between wpmu_create_user(), create_user(), and wp_insert_user(). The former two are wrappers, and do different things but potential to consolidate and clean up some old code.

Per Nacin:

nacin: wpmu_create_user() should probably just go away.

nacin: fairly useless function

nacin: by default, it looks like wp_insert_user() would create a role-less user.

nacin: as would wp_create_user()

Looking at wp_insert_user() it sets the default role if none is provided, where wpmu_create_user() would actually delete the default roles and caps.

Although, I'm not really sure there's a use case where you'd be using both the wpmu_new_user and user_register hooks simultaneously so possibly depreciate the former in favor of the latter.

One real issue with wpmu_create_user is that it returns false instead of the WP_Error object which is probably not desired since the error could be useful. The false return is used in wpmu_activate_signup() to either set the returned ID or create it's own WP_Error.

Lastly... documentation for create_user says it returns the ID, but it looks like it could potentially also return a WP_Error object. Didn't test, but possible documentation fix there.

Change History (5)

comment:1 scribu19 months ago

  • Type changed from defect (bug) to enhancement

One real issue with wpmu_create_user is that it returns false instead of the WP_Error object which is probably not desired since the error could be useful.

All the more reason to deprecate it.

comment:2 SergeyBiryukov19 months ago

  • Version changed from trunk to 3.0

comment:3 ryanduff19 months ago

Thanks Sergey for fixing the version. I always forget that. Wish we could get it changed to "Earliest Version"

As far as depreciating... that's fine. Perhaps roll all of wpmu_create_user() into wp_insert_user() since that's what does most of the heavy lifting? The only real difference is that the former deletes roles/caps until they're assigned to a site. Maybe we can just check if it's a network install and if so do that within wp_insert_user()?

Any other suggestions?

comment:4 jeremyfelt3 months ago

  • Milestone changed from Awaiting Review to Future Release

Looks like we could work toward deprecating wpmu_create_user().

comment:5 jeremyfelt3 months ago

  • Component changed from Multisite to Users
  • Focuses multisite added
Note: See TracTickets for help on using tickets.