Plugin Directory

Changeset 438200


Ignore:
Timestamp:
09/14/2011 06:42:54 PM (15 years ago)
Author:
AdamBackstrom
Message:

$current_user is only correct for the profile page; correctly use incoming $user_id when editing other users.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • alternate-contact-info/branches/AdamBackstrom/altcontact.php

    r266322 r438200  
    2929   
    3030        return $user;
    31     }else{
    32         return false;
    33     }
     31    }
     32
     33    return false;
    3434}
    3535
     
    128128}
    129129
    130 function ac_user_profile_save() {
     130function ac_user_profile_save( $user_id ) {
    131131    global $errors, $wpdb, $wptix, $current_user, $current_site;
    132132    $errors = new WP_Error();
    133133
     134    if( $user_id == $current_user->ID ) {
     135        $user = $current_user;
     136    } else {
     137        $user = get_userdata( $user_id );
     138    }
     139
    134140    // is there a wptix confirmation code in the mix?
    135141    if( isset( $_POST['phone_confirmation'] ) && ( !empty( $_POST['phone_confirmation'] ))){
    136         if( ( $ticket = $wptix->is_ticket( $_POST['phone_confirmation'] )) && $ticket->arg['user_id'] == $current_user->ID ){
     142        if( ( $ticket = $wptix->is_ticket( $_POST['phone_confirmation'] )) && $ticket->arg['user_id'] == $user->ID ){
    137143            $wptix->do_ticket( $_POST['phone_confirmation'] );
    138144        }else{
     
    143149
    144150    // is the primary email address changing?
    145     if( isset( $_POST['email'] ) && ( $current_user->user_email != sanitize_email( $_POST['email'] ))) {
     151    if( isset( $_POST['email'] ) && ( $user->user_email != sanitize_email( $_POST['email'] ))) {
    146152
    147153        $_POST['email'] = sanitize_email( $_POST['email'] );
     
    160166
    161167        // delete any previous addys waiting to be confirmed
    162         if( $waiting = get_usermeta( $current_user->ID, 'email_waiting' ))
    163             ac_delete_waiting( $current_user->ID, 'email', $waiting['ticket'] );
     168        if( $waiting = get_usermeta( $user->ID, 'email_waiting' ))
     169            ac_delete_waiting( $user->ID, 'email', $waiting['ticket'] );
    164170
    165171        // notify user to confirm new addy
    166         ac_notify_email( $current_user, $_POST['email'], 'email' );
     172        ac_notify_email( $user, $_POST['email'], 'email' );
    167173
    168174        // reset the email address to the current
    169         $_POST['email'] = $current_user->user_email;
     175        $_POST['email'] = $user->user_email;
    170176    }
    171177
    172178    // is the alternate email address changing?
    173     if( isset( $_POST['email_alt'] ) && ( $current_user->email_alt != sanitize_email( $_POST['email_alt'] ))) {
     179    if( isset( $_POST['email_alt'] ) && ( $user->email_alt != sanitize_email( $_POST['email_alt'] ))) {
    174180
    175181        $_POST['email_alt'] = sanitize_email( $_POST['email_alt'] );
     
    188194
    189195        // delete any previous addys waiting to be confirmed
    190         if( $waiting = get_usermeta( $current_user->ID, 'email_alt_waiting' ))
    191             ac_delete_waiting( $current_user->ID, 'email_alt', $waiting['ticket'] );
     196        if( $waiting = get_usermeta( $user->ID, 'email_alt_waiting' ))
     197            ac_delete_waiting( $user->ID, 'email_alt', $waiting['ticket'] );
    192198
    193199        // notify user to confirm new addy
    194         ac_notify_email( $current_user, $_POST['email_alt'], 'email_alt' );
     200        ac_notify_email( $user, $_POST['email_alt'], 'email_alt' );
    195201    }
    196202
    197203    // is the phone number changing?
    198     if( isset( $_POST['phone'] ) && ( $current_user->phone != sanitize_phone( $_POST['phone'] ))) {
     204    if( isset( $_POST['phone'] ) && ( $user->phone != sanitize_phone( $_POST['phone'] ))) {
    199205
    200206        $_POST['phone'] = sanitize_phone( $_POST['phone'] );
     
    213219
    214220        // delete any previous phones waiting to be confirmed
    215         if( $waiting = get_usermeta( $current_user->ID, 'phone_waiting' ))
    216             ac_delete_waiting( $current_user->ID, 'phone', $waiting['ticket'] );
     221        if( $waiting = get_usermeta( $user->ID, 'phone_waiting' ))
     222            ac_delete_waiting( $user->ID, 'phone', $waiting['ticket'] );
    217223
    218224        // notify user to confirm new addy
    219         if( ! ac_notify_phone( $current_user, $_POST['phone'], 'phone' )){
     225        if( ! ac_notify_phone( $user, $_POST['phone'], 'phone' )){
    220226            $errors->add( 'user_phone', __( "<strong>ERROR</strong>: The confirmation message could not be sent. The entered phone number may not be a valid cell phone, please check and try again." ), array( 'form-field' => 'phone' ) );
    221227            return;
     
    372378
    373379function ac_init(){
    374     add_action( 'personal_options_update', 'ac_user_profile_save' );
    375     add_action( 'edit_user_profile_update', 'ac_user_profile_save' );
     380    add_action( 'personal_options_update', 'ac_user_profile_save', 10, 1 );
     381    add_action( 'edit_user_profile_update', 'ac_user_profile_save', 10, 1 );
    376382
    377383    if( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) || strpos( $_SERVER['PHP_SELF'], 'user-edit.php' )) {
Note: See TracChangeset for help on using the changeset viewer.