At present the MembershipID is only exposed server-side, so you need to make that accessible client-side. For you this is the most efficient approach;
Setup a Webflow webhook to fire when a new user is created. Connect that to a webhook URL on your favorite automation platform. When a new user is created, at that moment, in that webhook event, you’ll have the user’s ID.
Have your server side automation turn around and immediately update that same Member record, pushing that user_id into a custom Member field you’ve already created. Now, that ID is accessible on the /user-account page as a custom field.
On the User Account page, add that field so it’s accessible in the HTML, and then wrap it in a hidden DIV. You want Webflow to populate it, but no need for users to see their userID. You especially don’t want them to edit it. Add an HTML ID to this input element as well, like user_id so that you can reference it easily.
Now for the most awkward part; you need to write a script that will access that data.
User custom fields are currently only available on the /user-account page, which means your script has to get it from there. Your script will;
Verify the user is logged in ( check for the wf logged in cookie )
Create an IFRAME, which loads /user-account. Make sure to use a relative path, so the hostname passes the same-domain CORS test. Webflow membership sites and e-commerce sites specify self as an IFRAME ancestor restriction.
Wait roughly 3 seconds… this is the tricky part, the population scripts are slow and they set the value of the input. As such there is no possibility to trigger via a mutation observer. You basically have to poll it every 200ms and wait for some value to be returned.
Once it’s there, grab that value.
You will want to cache that ID but that’s another layer of complexity, because you have to know when to clear it, and there is no logout page. I store it in sessionStorage ( not localStorage ), and clear it any time the user visits the /log-in page, or any time the login cookie test returns false.
Hey Chris and Michael, thanks both for the clever answers! I understands what you suggest, although is not straightforward. It makes me think that maybe changing the log in system to Firebase is possibly easier. Will work further on the topic. Thanks again!
If you utilize Firebase, you will still need to set conditional Logic. (Wized/Xano)
Xano can take user id and Firebase Auth and has a “hooked” Webflow connect. Wized will generate “secure” user ID. If you utilize Webflow’s Subscription ID to reference a status collection and then use Filters to Show Hide User lists in Template, you should be able to manage custom User Attributes in Collections with real time tagging.