Skip to:
Content

BuddyPress.org

Changeset 8184


Ignore:
Timestamp:
03/27/2014 11:36:09 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Clean up BP_Signup class.

  • Fix issue with sign-up meta not being populated correctly.
  • Remove stray semi-colons.
  • Code formatting clean-up.
  • See #5374.
File:
1 edited

Legend:

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

    r8121 r8184  
    9393
    9494        $signups_table = buddypress()->members->table_name_signups;
    95 
    96         $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$signups_table} WHERE signup_id = %d AND active = 0", $this->id ) );
     95        $signup        = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$signups_table} WHERE signup_id = %d AND active = 0", $this->id ) );
    9796
    9897        $this->avatar         = get_avatar( $signup->user_email, 32 );
     
    10099        $this->user_email     = $signup->user_email;
    101100        $this->meta           = maybe_unserialize( $signup->meta );
    102         $this->user_name      = ! empty( $meta['field_1'] ) ? wp_unslash( $meta['field_1'] ) : '';
     101        $this->user_name      = ! empty( $this->meta['field_1'] ) ? wp_unslash( $this->meta['field_1'] ) : '';
    103102        $this->registered     = $signup->registered;
    104103        $this->activation_key = $signup->activation_key;
     
    136135
    137136        // @todo whitelist sanitization
    138         if ( $r['orderby'] != 'signup_id' ) {
     137        if ( $r['orderby'] !== 'signup_id' ) {
    139138            $r['orderby'] = 'user_' . $r['orderby'];
    140139        }
     
    149148
    150149        if ( empty( $r['include'] ) ) {
     150
    151151            // Search terms
    152152            if ( ! empty( $r['usersearch'] ) ) {
    153153                $search_terms_clean = esc_sql( esc_sql( $r['usersearch'] ) );
    154154                $search_terms_clean = like_escape( $search_terms_clean );
    155                 $sql['where'][] = "( user_login LIKE '%" . $search_terms_clean . "%' OR user_email LIKE '%" . $search_terms_clean . "%' OR meta LIKE '%" . $search_terms_clean . "%' )";
     155                $sql['where'][]     = "( user_login LIKE '%" . $search_terms_clean . "%' OR user_email LIKE '%" . $search_terms_clean . "%' OR meta LIKE '%" . $search_terms_clean . "%' )";
    156156            }
    157157
     
    189189        foreach ( (array) $paged_signups as $key => $signup ) {
    190190
    191             $signup->id = intval( $signup->signup_id );
     191            $signup->id   = intval( $signup->signup_id );
    192192
    193193            $signup->meta = ! empty( $signup->meta ) ? maybe_unserialize( $signup->meta ) : false;
     
    306306
    307307        if ( is_wp_error( $user_id ) || empty( $user_id ) ) {
    308             $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' ) ) );
     308            $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' ) ) );
    309309            return $errors;
    310310        }
     
    318318        // signups don't appear in various user counts.
    319319        delete_user_option( $user_id, 'capabilities' );
    320         delete_user_option( $user_id, 'user_level' );
     320        delete_user_option( $user_id, 'user_level'   );
    321321
    322322        // Set any profile data
     
    354354        global $wpdb;
    355355
    356         if ( empty( $user_id ) )
    357             return false;
     356        if ( empty( $user_id ) ) {
     357            return false;
     358        }
    358359
    359360        $user_status = $wpdb->get_var( $wpdb->prepare( "SELECT user_status FROM {$wpdb->users} WHERE ID = %d", $user_id ) );
     
    494495        foreach ( $signups as $signup ) {
    495496
    496             $meta = $signup->meta;
    497             $meta['sent_date'] = current_time( 'mysql', true );
     497            $meta               = $signup->meta;
     498            $meta['sent_date']  = current_time( 'mysql', true );
    498499            $meta['count_sent'] = $signup->count_sent + 1;
    499500
     
    507508
    508509                if ( ! empty( $user_id ) && 2 != self::check_user_status( $user_id ) ) {
     510
    509511                    // Status is not 2, so user's account has been activated
    510                     $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );;
     512                    $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
     513
    511514                    // repare signups table
    512515                    self::validate( $signup->activation_key );
     516
    513517                    continue;
    514518
     
    562566            if ( ! empty( $user->errors ) ) {
    563567
    564                 if ( $user_id = username_exists( $signup->user_login ) && 2 != self::check_user_status( $user_id ) ) {
     568                $user_id = username_exists( $signup->user_login ) && 2 != self::check_user_status( $user_id );
     569
     570                if ( !empty( $user_id ) ) {
     571
    565572                    // Status is not 2, so user's account has been activated
    566573                    $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
     574
    567575                    // repare signups table
    568576                    self::validate( $signup->activation_key );
     
    616624
    617625                if ( 2 != self::check_user_status( $user_id ) ) {
     626
    618627                    // Status is not 2, so user's account has been activated
    619628                    $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
     629
    620630                    // repare signups table
    621631                    self::validate( $signup->activation_key );
Note: See TracChangeset for help on using the changeset viewer.