I have been following this sample code from
select
documentation:
https://payloadcms.com/docs/fields/select#:~:text=const%20%7B%20user%20%7D%20%3D%20useAuth()%3BBasically, I have created a custom select field that holds roles for different users, but, I have noticed that after changing the role of the user there,
user
object coming from
useAuth()
does not update the user data (i.e. keeps the old role of the user before the update) unless I logout and login again then it will only be updated. Is there a way on how I can refresh the user object there so it can update dynamically once the user's role is updated?
There is an undocumented function exposed through the useForm hook,
fetchFullUser
that you can call after updating the user.
const { fetchFullUser } = useForm()
Thank you @jarrod_not_jared! I'll give it a try 🙂
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.