onInvitationAccepted hook not triggering when invitation is accepted
I'm using the Better Auth organization plugin (v1.3.34) and trying to execute custom logic when a learner accepts an invitation. I've configured the onInvitationAccepted hook in my organization plugin setup:
organization({
async sendInvitationEmail(data) {
// ... email sending logic
},
async onInvitationAccepted(data) {
console.log("
Invitation accepted:", data);
// Custom enrollment logic here
},
})
Issue:
The onInvitationAccepted hook is not triggering at all when users accept invitations via authClient.organization.acceptInvitation(). No console logs appear in the server terminal, and the custom logic never executes.
Workaround:
I've implemented a client-side workaround by manually calling my server action immediately after acceptInvitation() succeeds, which works but feels less clean than using the built-in hook.
Questions:
Is onInvitationAccepted expected to work reliably in the current version?
Are there any special configuration requirements for this hook to trigger?
Is there a better pattern for executing server-side logic after invitation acceptance?
Any guidance would be appreciated!
organization({
async sendInvitationEmail(data) {
// ... email sending logic
},
async onInvitationAccepted(data) {
console.log("
// Custom enrollment logic here
},
})
Issue:
The onInvitationAccepted hook is not triggering at all when users accept invitations via authClient.organization.acceptInvitation(). No console logs appear in the server terminal, and the custom logic never executes.
Workaround:
I've implemented a client-side workaround by manually calling my server action immediately after acceptInvitation() succeeds, which works but feels less clean than using the built-in hook.
Questions:
Is onInvitationAccepted expected to work reliably in the current version?
Are there any special configuration requirements for this hook to trigger?
Is there a better pattern for executing server-side logic after invitation acceptance?
Any guidance would be appreciated!