Reply To: Stop confirmation email from settings change email
Sorry for all the updates, I have found the problem. In bp-settings-actions.php there is a line in the default handling of a password change that says this: $_POST[’email’] = $update_user->user_email;
By commenting that line out, it fixes the problem and my code works. It’s not ideal though as whenever I update buddypress it’ll change back. So if anyone knows a way around that then that would be great.
Otherwise I have a working script. For future reference it’s here:
function action_bp_core_general_settings_after_save() {
$useremail = $_POST[’email’];
$userpassword = $_POST[‘pwd’];
$current_user = wp_get_current_user();
if(wp_check_password( $userpassword, $current_user->user_pass, $current_user->ID)) {
if ( $current_user->user_email != $useremail ) {
delete_user_meta( $current_user->ID, ‘pending_email_change’ );
$userdata = array(
‘ID’ => $current_user->ID,
‘user_login’ => $current_user->user_login,
‘user_email’ => $useremail
);
$result = wp_insert_user( $userdata );
}
}
};
add_action( ‘bp_core_general_settings_after_save’,’action_bp_core_general_settings_after_save’ );