Ticket #2517: 2517.002.patch
File 2517.002.patch, 4.8 KB (added by , 15 years ago) |
---|
-
buddypress/bp-core/bp-core-settings.php
34 34 35 35 $bp_settings_updated = false; 36 36 $pass_error = false; 37 $email_error = false; 38 $pwd_error = false; 37 39 38 40 if ( isset($_POST['submit']) ) { 39 41 check_admin_referer('bp_settings_general'); … … 41 43 require_once( WPINC . '/registration.php' ); 42 44 43 45 // Form has been submitted and nonce checks out, lets do it. 46 47 //we want to validate the user again for the current password when making a big change 48 if ( !empty( $_POST['pwd'] ) && $_POST['pwd'] != '' && wp_check_password($_POST['pwd'], $current_user->user_pass, $current_user->ID) ) { 49 50 //need to make sure changing an email address does not already exist 51 if ( $_POST['email'] != '' ) { 52 53 //what is missing from the profile page vs signup - lets double check the goodies 54 $user_email = sanitize_email( wp_specialchars( trim( $_POST['email'] ) ) ); 55 56 if ( !is_email( $user_email ) ) 57 $email_error = true; 58 59 $limited_email_domains = get_site_option( 'limited_email_domains', 'buddypress' ); 60 61 if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) { 62 $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) ); 63 64 if ( in_array( $emaildomain, (array)$limited_email_domains ) == false ) 65 $email_error = true; 66 } 67 68 if ( !$email_error && $current_user->user_email != $user_email ) { 69 70 //we don't want email dups in the system 71 if ( email_exists( $user_email ) ) 72 $email_error = true; 73 74 if (!$email_error) 75 $current_user->user_email = $user_email; 76 } 77 } 78 79 if ( $_POST['pass1'] != '' && $_POST['pass2'] != '' ) { 80 81 if ( $_POST['pass1'] == $_POST['pass2'] && !strpos( " " . $_POST['pass1'], "\\" ) ) 82 $current_user->user_pass = $_POST['pass1']; 83 else 84 $pass_error = true; 44 85 45 if ( $_POST['email'] != '' ) 46 $current_user->user_email = wp_specialchars( trim( $_POST['email'] ) ); 47 48 if ( $_POST['pass1'] != '' && $_POST['pass2'] != '' ) { 49 if ( $_POST['pass1'] == $_POST['pass2'] && !strpos( " " . $_POST['pass1'], "\\" ) ) 50 $current_user->user_pass = $_POST['pass1']; 51 else 86 } else if ( empty( $_POST['pass1'] ) && !empty( $_POST['pass2'] ) || !empty( $_POST['pass1'] ) && empty( $_POST['pass2'] ) ) { 52 87 $pass_error = true; 53 } else if ( empty( $_POST['pass1'] ) && !empty( $_POST['pass2'] ) || !empty( $_POST['pass1'] ) && empty( $_POST['pass2'] ) ) { 54 $pass_error = true; 88 } else { 89 unset( $current_user->user_pass ); 90 } 91 92 if ( !$email_error && !$pass_error && wp_update_user( get_object_vars( $current_user ) ) ) 93 $bp_settings_updated = true; 94 55 95 } else { 56 unset( $current_user->user_pass );96 $pwd_error = true; 57 97 } 58 59 if ( !$pass_error && wp_update_user( get_object_vars( $current_user ) ) ) 60 $bp_settings_updated = true; 98 61 99 } 62 100 63 101 add_action( 'bp_template_title', 'bp_core_screen_general_settings_title' ); … … 71 109 } 72 110 73 111 function bp_core_screen_general_settings_content() { 74 global $bp, $current_user, $bp_settings_updated, $pass_error ; ?>112 global $bp, $current_user, $bp_settings_updated, $pass_error, $pwd_error, $email_error; ?> 75 113 76 114 <?php if ( $bp_settings_updated && !$pass_error ) { ?> 77 115 <div id="message" class="updated fade"> … … 84 122 <p><?php _e( 'Your passwords did not match', 'buddypress' ) ?></p> 85 123 </div> 86 124 <?php } ?> 125 126 <?php if ( $pwd_error && !$bp_settings_updated ) { ?> 127 <div id="message" class="error fade"> 128 <p><?php _e( 'Your password is incorrect', 'buddypress' ) ?></p> 129 </div> 130 <?php } ?> 131 132 <?php 133 if ( $email_error && !$bp_settings_updated ) { ?> 134 <div id="message" class="error fade"> 135 <p><?php _e( 'Sorry, that email address is already used or is invalid', 'buddypress' ) ?></p> 136 </div> 137 <?php } ?> 138 87 139 88 140 <form action="<?php echo $bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/general' ?>" method="post" class="standard-form" id="settings-form"> 141 142 <label for="pwd"><?php _e( 'Current Password <span>(required to update email or change current password)</span>', 'buddypress' ) ?></label> 143 <input type="password" name="pwd" id="pwd" size="16" value="" class="settings-input small" /> <?php _e( 'Current Password', 'buddypress' ) ?><br /> 144 <a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a><br/> 145 89 146 <label for="email"><?php _e( 'Account Email', 'buddypress' ) ?></label> 90 147 <input type="text" name="email" id="email" value="<?php echo attribute_escape( $current_user->user_email ); ?>" class="settings-input" /> 91 148