[buddypress-trac] [BuddyPress Trac] #6259: user_name / username checks in bp_core_validate_user_signup

buddypress-trac noreply at wordpress.org
Thu Feb 26 23:38:11 UTC 2015


#6259: user_name / username checks in bp_core_validate_user_signup
---------------------------------+-----------------------------
 Reporter:  anthony.bartoli      |      Owner:
     Type:  idea                 |     Status:  new
 Priority:  normal               |  Milestone:  Awaiting Review
Component:  Component - Members  |    Version:  2.2.1
 Severity:  normal               |   Keywords:  dev-feedback
---------------------------------+-----------------------------
 bp_core_validate_user_signup() in bp-members-functions.php seems to have
 technically unnecessary rules when validating the username:

 {{{
 $errors->add( 'user_name',  __( 'Username must be at least 4 characters',
 'buddypress' ) );

 $errors->add( 'user_name', __( 'Sorry, usernames may not contain the
 character "_"!', 'buddypress' ) );

 $errors->add( 'user_name', __( 'Sorry, usernames must have letters too!',
 'buddypress' ) );
 }}}

 Because WP_Error only allows you to remove *all* errors
 (WP_Error->remove()) for a given code, using the same code ("user_name")
 for these checks is especially problematic if I wanted to get rid of one
 condition(s) while keeping other(s).

 For example, I think many BP admins would not want community members using
 all numbers for a username but the current 4-character length requirement
 seems particularly subjective.

 If these checks were to be removed, is there an automated suite of tests
 that could be ran  to ensure that other BP functions would not break?

 If no such tests exist, perhaps a safe fix would be to use a unique
 WP_Error code so that they can be removed individually with
 WP_Error->remove() by hooking onto the bp_core_validate_user_signup
 filter.

 As of now, to eliminate one requirement while keeping the others, a
 developer would have no choice but to hack core BP, or remove all the
 username requirements (WP_Error->remove('user_name') or manually parse,
 filter, and rebuild $result!['errors'].

 So this is not a bug per se, but I think these username conditions could
 be re-written in a more flexible manner - assuming they are even required.

 I'd be more than happy to write a patch if my observations are correct. I
 am somewhat new to BP and WP development, so I look forward to hearing
 your feedback on this.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6259>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list