Home Forums General Issues User profile form: Update password? Reply To: User profile form: Update password?

  • Aaaah, you biscuit 🙂

    Sorted, thanks very much! Had to add a couple lines to update the user’s cookie so the password change doesn’t log them out immediately.

    Here’s the final function that’s working for me:

    add_filter('acf/pre_save_post', 'my_update_password');
    function my_update_password($post_id) {
    	if (substr($post_id, 0 , 5) != 'user_') {
    		// not a user
    		return $post_id;
    	$new_password = $_POST['acf']['field_55c0cfff1d979']; // update this
    	$who = str_replace('user_', '', $post_id);
    	wp_set_password( $new_password, $who );
    	wp_set_current_user ( $who );
    	wp_set_auth_cookie  ( $who );