# Registering after hook for WriteStorageObjects

**URL:** <https://forum.heroiclabs.com/t/registering-after-hook-for-writestorageobjects/4147>\
**Category:** Game Design\
**Tags:** storage\
**Created:** [July 27, 2023, 12:47pm UTC](https://forum.heroiclabs.com/t/registering-after-hook-for-writestorageobjects/4147 "2023-07-27T12:47:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![totebo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/totebo/32/528_2.png) [@totebo](https://forum.heroiclabs.com/u/totebo)\
**Post date:** [July 27, 2023, 12:47pm UTC](https://forum.heroiclabs.com/t/registering-after-hook-for-writestorageobjects/4147/1 "2023-07-27T12:47:05Z")

</div>

Using a Lua module, the after hook for `AuthenticateCustom` fires. Fresh data is being saved to a user storage object, but for some reason the after hook for `WriteStorageObjects` doesn’t fire.

Any idea why this might be? I’m using the ids from [the documentation](https://heroiclabs.com/docs/nakama/guides/server-framework/using-hooks/).

This is the code:

```auto
local function on_after_authenticate_custom(context, payload)
  
  print("on_after_authenticate_custom()")

end

local function on_after_write_storage_objects(context, payload)

  print("on_after_write_storage_objects()")

end

nk.register_req_after(on_after_authenticate_custom, "AuthenticateCustom") 
nk.register_req_after(on_after_write_storage_objects, "WriteStorageObjects")

```

---

<div class="post-metadata">

**Author:** ![flavio](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/flavio/32/2161_2.png) [@flavio](https://forum.heroiclabs.com/u/flavio)\
**Post date:** [July 28, 2023, 8:46am UTC](https://forum.heroiclabs.com/t/registering-after-hook-for-writestorageobjects/4147/2 "2023-07-28T08:46:27Z")

</div>

Hello @totebo,

Before and after hooks are only applied to client messages/API calls. If you want to reuse the logic, you can extract it and call it explicitly in both hooks.

In the runtime, you should be able to express complex code and patterns.

---

<div class="post-metadata">

**Author:** ![totebo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/totebo/32/528_2.png) [@totebo](https://forum.heroiclabs.com/u/totebo)\
**Post date:** [July 28, 2023, 4:29pm UTC](https://forum.heroiclabs.com/t/registering-after-hook-for-writestorageobjects/4147/3 "2023-07-28T16:29:16Z")

</div>

Got it. Thanks for the reply!
