Skip to:
Content

BuddyPress.org

Changeset 5840


Ignore:
Timestamp:
02/25/2012 06:21:27 PM (13 years ago)
Author:
boonebgorges
Message:

Some hardening of the member registration process:

  • Ensures that pre_user_login filters are applied before attempting to create a user with wp_insert_user(), so that BP's username validation is the same as WP's, and username_exists() checks are reliable.
  • Check to see whether the return value of wp_insert_user() is a WP_Error object before continuing with the registration process.
  • Improves error handling during user creation, by correctly parsing WP_Error objects returned from wp_insert_user().

See #3949.

Location:
trunk/bp-members
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-members/bp-members-functions.php

    r5837 r5840  
    949949    $user_email = sanitize_email( $user_email );
    950950
     951    // Apply any user_login filters added by BP or other plugins before validating
     952    $user_name = apply_filters( 'pre_user_login', $user_name );
     953
    951954    if ( empty( $user_name ) )
    952955        $errors->add( 'user_name', __( 'Please enter a username', 'buddypress' ) );
     
    10321035        ) );
    10331036
    1034         if ( empty( $user_id ) ) {
     1037        if ( is_wp_error( $user_id ) || empty( $user_id ) ) {
    10351038            $errors->add( 'registerfail', sprintf( __('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'buddypress' ), bp_get_option( 'admin_email' ) ) );
    10361039            return $errors;
  • trunk/bp-members/bp-members-screens.php

    r5837 r5840  
    189189                // Finally, sign up the user and/or blog
    190190                if ( isset( $_POST['signup_with_blog'] ) && is_multisite() )
    191                     bp_core_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
     191                    $wp_user_id = bp_core_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
    192192                else
    193                     bp_core_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta );
    194 
    195                 $bp->signup->step = 'completed-confirmation';
     193                    $wp_user_id = bp_core_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta );
     194
     195                if ( is_wp_error( $wp_user_id ) ) {                 
     196                    $bp->signup->step = 'request-details';
     197                    bp_core_add_message( $wp_user_id->get_error_message(), 'error' );
     198                } else {
     199                    $bp->signup->step = 'completed-confirmation';
     200                }
    196201            }
    197202
Note: See TracChangeset for help on using the changeset viewer.