Hi,
read-only link: Webflow - cheffle v1
published site: https://cheffle-v1.webflow.io/
I’ve recently noticed that, after logging in, the user object does not load any data (like stated in the docs at /sa5-user-accounts/get-logged-in-user-info/the-user-object/the-user-object-lifecycle).
The user object and all custom fields etc are only loaded after:
- Closing all tabs and reopening them (still logged in)
- Going to the user account page and saving changes (even when you’ve changed nothing)
This happens after fresh account creation, but also after logging in to an existing account in a fresh session.
I need to be able to fetch user information immediately after a login, so that I can send the user-id (inputted into a custom field) towards my Stripe checkout session.
This is the code in my head
<!-- Sygnal Attributes 5 | User Accounts -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@5.4.6/dist/css/webflow-membership.css">
<script defer src="https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@5.4.6/dist/nocode/webflow-membership.js"></script>
<script>
window.sa5 = window.sa5 || [];
window.sa5.push(['getMembershipConfig',
(config) => {
// Apply any configuration settings here
// such as access groups
return config;
}]);
</script>
and this is the code in my page (e.g. /kookplannen/italiaanse-avond)
<script>
window.sa5 = window.sa5 || [];
window.sa5.push(['userInfoChanged',
(user) => {
console.log('SA5 userInfoChanged triggered');
// Globale variabelen om gebruikersinformatie op te slaan
window.userId = null;
window.userEmail = null;
window.userName = null;
// Check of de custom fields geladen zijn
if (user.user_data_loaded.custom_fields) {
console.log('Custom fields loaded');
// Sla de benodigde informatie op in globale variabelen
window.userId = user.data["user-id"];
window.userEmail = user["email"];
window.userName = user["name"];
console.log('User ID:', window.userId);
console.log('User Email:', window.userEmail);
console.log('User Name:', window.userName);
} else {
console.error('User data not available');
}
}
]);
</script>
Any idea how to solve this?