Opened 10 years ago
Last modified 5 years ago
#31106 new enhancement
Introduce nicename_exists
Reported by: | voldemortensen | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Users | Keywords: | has-patch |
Focuses: | Cc: |
Description
Currently there are functions for username_exists and email_exists, but none for nicename_exists. Patch introduces nicename_exists with accompanying unit tests.
Related: #30647
Attachments (1)
Change History (6)
#3
@
10 years ago
I think
if(!nicename_exists( 'stuff' ) ) { things(); }
looks cleaner and more readable than
if(!get_user_by( 'slug', 'stuff' ) ) { things(); }
Which raises another issue of 'slug' being slightly confusing. It would make more sense if get_user_by( 'nicename', 'stuff' )
available.
#4
@
10 years ago
Additionally, the more I think about it the more it semantically makes sense.
get_user_by seems to be used with the expectation that a user will be returned and error if the user doesn't exist. *_exists seem to be used when we aren't sure or are hoping that a user doesn't exist.
I'm not sure we need to bother with this — I'd rather encourage usage of get_user_by(), which is a bit newer than the other _exists() functions. Thoughts?