[wp-trac] [WordPress Trac] #27317: Update wp_insert_user function to return 'pre_user_login' filter WP_Errors
WordPress Trac
noreply at wordpress.org
Fri Mar 7 16:29:05 UTC 2014
#27317: Update wp_insert_user function to return 'pre_user_login' filter WP_Errors
------------------------------------------+-----------------------------
Reporter: crazycoolcam | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Users | Version:
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+-----------------------------
Changes (by danielbachhuber):
* keywords: => needs-patch needs-unit-tests
* milestone: Awaiting Review => Future Release
Comment:
I think the use case makes a lot of sense. Core already has the concept of
"Banned Names" for sites, and `wp_insert_user()` already returns
`WP_Error` in some cases.
Rather than bolting this onto `pre_user_login` though, I think I'd
recommend checking if `user_login` is in an array of banned usernames. If
it is, then return `WP_Error`. Something like this:
{{{
if ( in_array( $user_login, apply_filters( 'illegal_user_logins', array()
) ) ) {
return new WP_Error( 'illegal-user-login', __( "User login value is
not permitted." ) );
}}}
A few more things to note:
* Please create your patches from the WordPress root.
* It would be good to have unit tests included with the patch. If you use
the [https://develop.svn.wordpress.org/trunk/ developer checkout], you can
include the changes and the tests in the same patch file.
* Your second patch should be included as well — `edit_user()` should
handle cases in which the user isn't actually created.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27317#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list