Make WordPress Core

Opened 12 years ago

Last modified 5 years ago

#21910 new enhancement

wpmu_create_user() standardization

Reported by: ryanduff's profile ryanduff Owned by:
Milestone: Priority: normal
Severity: normal 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 (6)

#1 @scribu
12 years 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.

#2 @SergeyBiryukov
12 years ago

  • Version changed from trunk to 3.0

#3 @ryanduff
12 years 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?

#4 @jeremyfelt
10 years ago

  • Milestone changed from Awaiting Review to Future Release

Looks like we could work toward deprecating wpmu_create_user().

#5 @jeremyfelt
10 years ago

  • Component changed from Multisite to Users
  • Focuses multisite added

#6 @chriscct7
9 years ago

  • Severity changed from minor to normal

I think the easiest path forward here is deprecating the wpmu_create_user function.

Note: See TracTickets for help on using tickets.