Changeset 13292
- Timestamp:
- 07/06/2022 09:56:46 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-settings/actions/general.php
r13223 r13292 45 45 46 46 // Define local defaults 47 $bp = buddypress(); // The instance 48 $email_error = false; // invalid|blocked|taken|empty|nochange 49 $pass_error = false; // invalid|mismatch|empty|nochange 50 $pass_changed = false; // true if the user changes their password 51 $email_changed = false; // true if the user changes their email 52 $feedback_type = 'error'; // success|error 53 $feedback = array(); // array of strings for feedback. 47 $bp = buddypress(); // The instance 48 $email_error = false; // invalid|blocked|taken|empty|nochange 49 $pass_error = false; // invalid|mismatch|empty|nochange 50 $pass_changed = false; // true if the user changes their password 51 $email_changed = false; // true if the user changes their email 52 $feedback_type = 'error'; // success|error 53 $feedback = array(); // array of strings for feedback. 54 $user_id = bp_displayed_user_id(); // The ID of the user being displayed. 54 55 55 56 // Nonce check. 56 check_admin_referer( 'bp_settings_general');57 check_admin_referer( 'bp_settings_general' ); 57 58 58 59 // Validate the user again for the current password when making a big change. 59 if ( ( is_super_admin() ) || ( ! empty( $_POST['pwd'] ) && wp_check_password( $_POST['pwd'], $bp->displayed_user->userdata->user_pass, bp_displayed_user_id()) ) ) {60 if ( ( is_super_admin() ) || ( ! empty( $_POST['pwd'] ) && wp_check_password( $_POST['pwd'], $bp->displayed_user->userdata->user_pass, $user_id ) ) ) { 60 61 61 62 $update_user = array( 62 'ID' => (int) bp_displayed_user_id(),63 'ID' => (int) $user_id, 63 64 ); 64 65 … … 100 101 ); 101 102 102 bp_update_user_meta( bp_displayed_user_id(), 'pending_email_change', $pending_email );103 bp_update_user_meta( $user_id, 'pending_email_change', $pending_email ); 103 104 $verify_link = bp_displayed_user_domain() . bp_get_settings_slug() . '/?verify_email_change=' . $hash; 104 105 … … 106 107 $args = array( 107 108 'tokens' => array( 108 'displayname' => bp_core_get_user_displayname( bp_displayed_user_id()),109 'displayname' => bp_core_get_user_displayname( $user_id ), 109 110 'old-user.email' => $old_user_email, 110 111 'user.email' => $user_email, … … 182 183 // on the current page load. 183 184 if ( ( false === $email_error ) && ( false === $pass_error ) && ( wp_update_user( $update_user ) ) ) { 184 $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id());185 $bp->displayed_user->userdata = bp_core_get_core_userdata( $user_id ); 185 186 } 186 187 … … 227 228 } 228 229 229 // Set the feedback.230 bp_core_add_message( implode( "\n", $feedback ), $feedback_type);230 // Set the URL to redirect the user to. 231 $redirect_to = trailingslashit( bp_displayed_user_domain() . bp_get_settings_slug() . '/general' ); 231 232 232 233 /** … … 234 235 * 235 236 * @since 1.5.0 237 * @since 11.0.0 Add the `$user_id` & `$redirect_to` parameters. 238 * 239 * @param int $user_id The ID of the user being displayed. 240 * @param string $redirect_to The Default Front-end General Settings Screen URL. 236 241 */ 237 do_action( 'bp_core_general_settings_after_save' ); 242 do_action( 'bp_core_general_settings_after_save', $user_id, $redirect_to ); 243 244 // Set the feedback. 245 bp_core_add_message( implode( "\n", $feedback ), $feedback_type ); 238 246 239 247 // Redirect to prevent issues with browser back button. 240 bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_settings_slug() . '/general' ));248 bp_core_redirect( $redirect_to ); 241 249 } 242 250 add_action( 'bp_actions', 'bp_settings_action_general' );
Note: See TracChangeset
for help on using the changeset viewer.