Potential improvement to bp-members-classes.php -> add_backcompat()
-
We noticed that error messages generated by the WordPress core, for example when usernames already exist, weren’t being displayed but instead a generic message was being shown.
It appears that bp-members-classes.php -> add_backcompat() is not re-using the $errors sent from wp_insert_user() but is instead creating it’s own $errors object.
if ( is_wp_error( $user_id ) || empty( $user_id ) ) { $errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn’t register you. Please contact the <a href="mailto:%s">webmaster</a>.', 'buddypress' ), bp_get_option( 'admin_email' ) ) ); return $errors; }
We have changed our version to re-use the $user_id object instead, which, in the case where wp_insert_user() fails, contains the WordPress error object
Could we suggest that this is added (or similar) going forwards as it is handy to have the correct error messages from WordPress core returned?
Our minor change is:
if ( is_wp_error( $user_id ) || empty( $user_id ) ) { $errors = $user_id; //$errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn’t register you. Please contact the <a href="mailto:%s">webmaster</a>.', 'buddypress' ), bp_get_option( 'admin_email' ) ) ); return $errors; }
Thanks
[Buddy Press 2.1.1]
- The topic ‘Potential improvement to bp-members-classes.php -> add_backcompat()’ is closed to new replies.