Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/23/2012 07:27:29 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Tweak general settings logic to include boolean for successfully changed email address. See #4038, #4010.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-settings/bp-settings-actions.php

    r5829 r5832  
    4747    $pass_error    = false;   // invalid|mismatch|empty|nochange
    4848    $pass_changed  = false;   // true if the user changes their password
     49    $email_changed = false;   // true if the user changes their email
    4950    $feedback_type = 'error'; // success|error
    5051    $feedback      = array(); // array of strings for feedback
    5152
    52     /** Handle Form ***********************************************************/
    5353
    5454    if ( isset( $_POST['submit'] ) ) {
     
    6969                $user_email = sanitize_email( esc_html( trim( $_POST['email'] ) ) );
    7070
    71                 // Skip this if no change to email
     71                // User is changing email address
    7272                if ( $bp->displayed_user->userdata->user_email != $user_email ) {
    7373
     
    9393                    }
    9494
     95                    // Yay we made it!
     96                    if ( false === $email_error ) {
     97                        $update_user->user_email = $user_email;
     98                        $email_changed = true;
     99                    }
     100
    95101                // No change
    96102                } else {
    97                     $email_error = 'nochange';
    98                 }
    99 
    100                 // Yay we made it!
    101                 if ( false === $email_error ) {
    102                     $update_user->user_email = $user_email;
     103                    $email_error = false;
    103104                }
    104105
     
    124125            // Both password fields were empty
    125126            } elseif ( empty( $_POST['pass1'] ) && empty( $_POST['pass2'] ) ) {
    126                 $pass_error = 'nochange';
     127                $pass_error = false;
    127128
    128129            // One of the password boxes was left empty
     
    169170                $feedback['email_empty']    = __( 'Email address cannot be empty.', 'buddypress' );
    170171                break;
    171             case 'nochange' :
    172                 $email_error = false;
     172            case false :
     173                // No change
    173174                break;
    174175        }
     
    185186                $feedback['pass_empty']    = __( 'One of the password fields was empty.', 'buddypress' );
    186187                break;
    187             case 'nochange' :
    188                 $pass_error = false;
     188            case false :
     189                // No change
    189190                break;
    190191        }
    191192
    192193        // No errors so show a simple success message
    193         if ( ( false === $email_error ) && ( ( false == $pass_error ) && ( true === $pass_changed ) ) ) {
     194        if ( ( ( false === $email_error ) || ( false == $pass_error ) ) && ( ( true === $pass_changed ) || ( true === $email_changed ) ) ) {
    194195            $feedback[]    = __( 'Your settings have been saved.', 'buddypress' );
    195196            $feedback_type = 'success';
    196197
    197198        // Some kind of errors occurred
    198         } elseif ( ( false === $email_error ) && ( ( false == $pass_error ) && ( false === $pass_changed ) ) ) {
     199        } elseif ( ( ( false === $email_error ) || ( false === $pass_error ) ) && ( ( false === $pass_changed ) || ( false === $email_changed ) ) ) {
    199200            if ( bp_is_my_profile() ) {
    200201                $feedback['nochange'] = __( 'No changes were made to your account.', 'buddypress' );
Note: See TracChangeset for help on using the changeset viewer.