# Using increment to update user

**URL:** <https://forum.getkirby.com/t/using-increment-to-update-user/24101>\
**Category:** Questions\
**Tags:** v3\
**Created:** [November 29, 2021, 2:03pm UTC](https://forum.getkirby.com/t/using-increment-to-update-user/24101 "2021-11-29T14:03:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikeharrison](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mikeharrison/32/9620_2.png) [@mikeharrison](https://forum.getkirby.com/u/mikeharrison)\
**Post date:** [November 29, 2021, 2:03pm UTC](https://forum.getkirby.com/t/using-increment-to-update-user/24101/1 "2021-11-29T14:03:46Z")

</div>

Hi,  
I am trying to use `increment()` to update the global tally of entrants to a competition, and also assign entry numbers to each one. I have the following in a `user.update:after` hook:

```auto
kirby()->site()->increment('successfulEntrants');
$entryNumber = kirby()->site()->successfulEntrants()->toInt();
            
$newUser->update([
   'entryNumber' => $entryNumber
]);

```

So when an editor updates the user, the `successfulEntrants` total is increased by one, and the user is given a corresponding `entryNumber`. The total is working as expected, but the `entryNumber` is always one behind, like it is using the total before it has had the increment applied. So for example, when approving the first entry the `successfulEntrants` changes to 1 (which is correct), but the user is given an `entryNumber` of 0

Can anyone see where I am going wrong here?

---

<div class="post-metadata">

**Author:** ![moonwalk](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@moonwalk](https://forum.getkirby.com/u/moonwalk)\
**Post date:** [November 29, 2021, 2:10pm UTC](https://forum.getkirby.com/t/using-increment-to-update-user/24101/2 "2021-11-29T14:10:01Z")

</div>

You have to store the result of updating in a new variable:

```auto
$newSite = kirby()->site()->increment('successfulEntrants');
$entryNumber = $newSite->successfulEntrants()->toInt();

```

---

<div class="post-metadata">

**Author:** ![mikeharrison](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mikeharrison/32/9620_2.png) [@mikeharrison](https://forum.getkirby.com/u/mikeharrison)\
**Post date:** [November 29, 2021, 4:11pm UTC](https://forum.getkirby.com/t/using-increment-to-update-user/24101/3 "2021-11-29T16:11:50Z")

</div>

Super, thanks that was just the job 👍
