Ticket #965: 965.diff
File 965.diff, 9.2 KB (added by , 14 years ago) |
---|
-
bp-core/bp-core-settings.php
23 23 24 24 if ( !is_super_admin() && empty( $bp->site_options['bp-disable-account-deletion'] ) ) 25 25 bp_core_new_subnav_item( array( 'name' => __( 'Delete Account', 'buddypress' ), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_delete_account', 'position' => 90, 'user_has_access' => bp_is_my_profile() ) ); 26 26 27 27 do_action( 'bp_core_settings_setup_nav' ); 28 28 } 29 29 add_action( 'bp_setup_nav', 'bp_core_add_settings_nav' ); … … 44 44 require_once( WPINC . '/registration.php' ); 45 45 46 46 // Form has been submitted and nonce checks out, lets do it. 47 47 48 48 // Validate the user again for the current password when making a big change 49 49 if ( !empty( $_POST['pwd'] ) && $_POST['pwd'] != '' && wp_check_password($_POST['pwd'], $current_user->user_pass, $current_user->ID) ) { 50 50 51 51 // Make sure changing an email address does not already exist 52 52 if ( $_POST['email'] != '' ) { 53 53 54 54 // What is missing from the profile page vs signup - lets double check the goodies 55 55 $user_email = sanitize_email( wp_specialchars( trim( $_POST['email'] ) ) ); 56 56 57 57 if ( !is_email( $user_email ) ) 58 58 $email_error = true; 59 59 60 60 $limited_email_domains = get_site_option( 'limited_email_domains', 'buddypress' ); 61 61 62 62 if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) { 63 63 $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) ); 64 64 65 65 if ( in_array( $emaildomain, (array)$limited_email_domains ) == false ) { 66 66 $email_error = true; 67 67 68 68 } 69 69 } 70 70 71 71 if ( !$email_error && $current_user->user_email != $user_email ) { 72 72 73 73 //we don't want email dups in the system 74 74 if ( email_exists( $user_email ) ) 75 75 $email_error = true; 76 76 77 77 if (!$email_error) 78 78 $current_user->user_email = $user_email; 79 79 } 80 80 } 81 81 82 82 if ( $_POST['pass1'] != '' && $_POST['pass2'] != '' ) { 83 83 84 84 if ( $_POST['pass1'] == $_POST['pass2'] && !strpos( " " . $_POST['pass1'], "\\" ) ) 85 85 $current_user->user_pass = $_POST['pass1']; 86 86 else 87 87 $pass_error = true; 88 88 89 89 } else if ( empty( $_POST['pass1'] ) && !empty( $_POST['pass2'] ) || !empty( $_POST['pass1'] ) && empty( $_POST['pass2'] ) ) { 90 90 $pass_error = true; 91 91 } else { 92 92 unset( $current_user->user_pass ); 93 93 } 94 94 95 95 if ( !$email_error && !$pass_error && wp_update_user( get_object_vars( $current_user ) ) ) 96 96 $bp_settings_updated = true; 97 97 98 98 } else { 99 99 $pwd_error = true; 100 100 } 101 101 102 102 do_action( 'bp_core_general_settings_after_save' ); 103 103 } 104 104 … … 126 126 <p><?php _e( 'Your passwords did not match', 'buddypress' ) ?></p> 127 127 </div> 128 128 <?php } ?> 129 129 130 130 <?php if ( $pwd_error && !$bp_settings_updated ) { ?> 131 131 <div id="message" class="error fade"> 132 132 <p><?php _e( 'Your password is incorrect', 'buddypress' ) ?></p> 133 133 </div> 134 134 <?php } ?> 135 135 136 <?php 136 <?php 137 137 if ( $email_error && !$bp_settings_updated ) { ?> 138 138 <div id="message" class="error fade"> 139 139 <p><?php _e( 'Sorry, that email address is already used or is invalid', 'buddypress' ) ?></p> … … 141 141 <?php } ?> 142 142 143 143 144 <form action="<?php echo $bp-> loggedin_user->domain . BP_SETTINGS_SLUG . '/general' ?>" method="post" class="standard-form" id="settings-form">144 <form action="<?php echo $bp->displayed_user->domain . BP_SETTINGS_SLUG . '/general' ?>" method="post" class="standard-form" id="settings-form"> 145 145 146 146 <label for="pwd"><?php _e( 'Current Password <span>(required to update email or change current password)</span>', 'buddypress' ) ?></label> 147 147 <input type="password" name="pwd" id="pwd" size="16" value="" class="settings-input small" /> <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> 148 148 149 149 <label for="email"><?php _e( 'Account Email', 'buddypress' ) ?></label> 150 <input type="text" name="email" id="email" value="<?php echo esc_attr( $current_user->user_email ); ?>" class="settings-input" /> 150 <p> 151 <input type="text" name="email" id="email" value="<?php echo esc_attr( $current_user->user_email ); ?>" class="settings-input" /> 152 </p> 151 153 152 154 <label for="pass1"><?php _e( 'Change Password <span>(leave blank for no change)</span>', 'buddypress' ) ?></label> 153 <input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small" /> <?php _e( 'New Password', 'buddypress' ) ?><br /> 154 <input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small" /> <?php _e( 'Repeat New Password', 'buddypress' ) ?> 155 155 <p> 156 <input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small" /> <?php _e( 'New Password', 'buddypress' ) ?><br /> 157 <input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small" /> <?php _e( 'Repeat New Password', 'buddypress' ) ?> 158 </p> 159 156 160 <?php do_action( 'bp_core_general_settings_before_submit' ) ?> 157 161 158 162 <div class="submit"> 159 163 <input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto" /> 160 164 </div> 161 165 162 166 <?php do_action( 'bp_core_general_settings_after_submit' ) ?> 163 167 164 168 <?php wp_nonce_field('bp_settings_general') ?> … … 169 173 /***** NOTIFICATION SETTINGS ******/ 170 174 171 175 function bp_core_screen_notification_settings() { 172 global $ current_user, $bp_settings_updated;176 global $bp, $bp_settings_updated; 173 177 174 178 $bp_settings_updated = false; 179 $current_user = set_current_user( $bp->displayed_user->id ); 175 180 176 181 if ( isset( $_POST['submit'] ) ) { 177 182 check_admin_referer('bp_settings_notifications'); 178 183 179 184 if ( isset( $_POST['notifications'] ) ) { 180 185 foreach ( (array)$_POST['notifications'] as $key => $value ) { 181 update_user_meta( (int)$ current_user->id, $key, $value );186 update_user_meta( (int)$bp->displayed_user->id, $key, $value ); 182 187 } 183 188 } 184 189 185 190 $bp_settings_updated = true; 186 191 187 192 do_action( 'bp_core_notification_settings_after_save' ); 188 193 } 189 194 … … 198 203 } 199 204 200 205 function bp_core_screen_notification_settings_content() { 201 global $bp, $ current_user, $bp_settings_updated; ?>206 global $bp, $bp_settings_updated; 202 207 208 $current_user = set_current_user( $bp->displayed_user->id ); 209 ?> 210 203 211 <?php if ( $bp_settings_updated ) { ?> 204 212 <div id="message" class="updated fade"> 205 213 <p><?php _e( 'Changes Saved.', 'buddypress' ) ?></p> 206 214 </div> 207 215 <?php } ?> 208 216 209 <form action="<?php echo $bp-> loggedin_user->domain . BP_SETTINGS_SLUG . '/notifications' ?>" method="post" id="settings-form">217 <form action="<?php echo $bp->displayed_user->domain . BP_SETTINGS_SLUG . '/notifications' ?>" method="post" id="settings-form"> 210 218 <p><?php _e( 'Send a notification by email when:', 'buddypress' ) ?></p> 211 219 212 220 <?php do_action( 'bp_notification_settings' ) ?> … … 216 224 </div> 217 225 218 226 <?php do_action( 'bp_core_notification_settings_after_submit' ) ?> 219 227 220 228 <?php wp_nonce_field('bp_settings_notifications') ?> 221 229 222 230 </form> … … 226 234 /**** DELETE ACCOUNT ****/ 227 235 228 236 function bp_core_screen_delete_account() { 237 global $bp; 238 229 239 if ( isset( $_POST['delete-account-understand'] ) ) { 230 240 check_admin_referer( 'delete-account' ); 231 241 232 242 // delete the users account 233 if ( bp_core_delete_account( ) )243 if ( bp_core_delete_account( $bp->displayed_user->id ) ) 234 244 bp_core_redirect( site_url() ); 235 245 } 236 246 … … 245 255 } 246 256 247 257 function bp_core_screen_delete_account_content() { 248 global $bp, $ current_user, $bp_settings_updated, $pass_error; ?>258 global $bp, $bp_settings_updated, $pass_error; 249 259 250 <form action="<?php echo $bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/delete-account'; ?>" name="account-delete-form" id="account-delete-form" class="standard-form" method="post"> 260 $current_user = set_current_user( $bp->displayed_user->id ); 261 ?> 251 262 263 <form action="<?php echo $bp->displayed_user->domain . BP_SETTINGS_SLUG . '/delete-account'; ?>" name="account-delete-form" id="account-delete-form" class="standard-form" method="post"> 264 252 265 <div id="message" class="info"> 253 266 <p><?php _e( 'WARNING: Deleting your account will completely remove ALL content associated with it. There is no way back, please be careful with this option.', 'buddypress' ); ?></p> 254 267 </div> … … 256 269 <input type="checkbox" name="delete-account-understand" id="delete-account-understand" value="1" onclick="if(this.checked) { document.getElementById('delete-account-button').disabled = ''; } else { document.getElementById('delete-account-button').disabled = 'disabled'; }" /> <?php _e( 'I understand the consequences of deleting my account.', 'buddypress' ); ?> 257 270 258 271 <?php do_action( 'bp_core_delete_account_before_submit' ) ?> 259 272 260 273 <div class="submit"> 261 274 <input type="submit" disabled="disabled" value="<?php _e( 'Delete My Account', 'buddypress' ) ?> →" id="delete-account-button" name="delete-account-button" /> 262 275 </div> 263 276 264 277 <?php do_action( 'bp_core_delete_account_after_submit' ) ?> 265 278 266 279 <?php wp_nonce_field('delete-account') ?>