SA5 Memberships documentation may need revision

The set up for SA5 Memberships reads (on this page) as follows:

STEP 1

Add this code to the site wide head section:

<!-- Sygnal Attributes 5 | Memberships --> 
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@5.3.4/dist/css/webflow-membership.css"> 
<script defer src="https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@5.3.4/dist/nocode/webflow-membership.js"></script>

STEP 2

Add the custom attribute and value specified in the documentation to the element in which you want that user data to appear (e.g. for ā€˜emailā€™ add wfu-bind = $user.email).

Set up complete :white_check_mark:

But this alone doesnā€™t work. You also need to add this code just after the code from the first step:

<script>
window.sa5 = window.sa5 || [];

// Insert some kind of config change here, e.g. access groups - as seen in the cloneable]

window.sa5.push(['userInfoChanged', 
  (user) => {
    console.log("USER INFO CHANGED", user); 
  }]);   
</script>

The documentation implies that this extra code is only required if you want to access the user data using Javascript. But without it the custom attributes approach doesnā€™t work, even if you just want to display the userā€™s email address (not any custom fields). Itā€™s even more confusing as the above two step process is exactly how SA4 Memberships worked - ā€˜Copy and paste this script, then add custom attributes where you want the data to appear.ā€™

An example of a complete code block that works from the very beginning can be found at the bottom of this page. If you add that code and then add a custom attribute to an element, it will work.

This took me an entire day to figure out. It was very frustrating. But please let me know if Iā€™ve misinterpreted something in the documentation.

1 Like

Hi Nathan,
The member attributes isnā€™t working for me at all when I try.
Could you help me figure out if I got the installation wrong?

Iā€™m trying to show user information when the page is loaded:
Staging: Blog
Preview: Webflow - Juniper

Signup page: Join The Club
Login: Juniper

Hi Nathan,

Thank you very much for this post. I spent some time trying to figure out why the Step 1 and 2 alone would not work for simply pulling in user email into prepopulated input field in a form. I have taken the full code you pointed to and it has worked.

I have access groups enabled (although I am not pulling any access group data at present, only standard user email). Could that be why it only works using the full membership BETA code?

Best,
Nathaniel

Hey Kudzi. Try the following:

  1. Add this code to the HEAD section in the custom code area in site settings (not the individual page):
<!-- Sygnal Attributes 5 | Memberships BETA -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@5.3.1-beta/dist/css/webflow-membership.css"> 
<script defer src="https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@5.3.1-beta/dist/nocode/webflow-membership.js"></script>
<script>
window.sa5 = window.sa5 || [];
window.sa5.push(['getMembershipConfig', 
  (config) => {
    config.accessGroupsFolder = '/sa5-ag';
    config.accessGroups = [
      'free', 'basic', 'pro', 'premium'
    ];
    return config;
  }]); 
window.sa5.push(['userInfoChanged', 
  (user) => {
    console.log("USER INFO CHANGED", user); 
  }]);   
</script>
  1. Add the appropriate custom attribute to the element in which you want user data to appear, e.g. to show their email, under that elementā€™s customer attributes, add the name wfu-bind and the value $user.email

Hey Nathaniel. That sounds like a reasonable deduction. Although I canā€™t remember specifically ā€œactivatingā€ access groups. That just happens when you activate Membershipsā€¦ I think? I thought there might be something in there that I donā€™t understand, but Iā€™ll wait to hear from the developers.

1 Like

That shouldnā€™t be necessary- if you look at the code you can see it doesnā€™t do anything except a console log. However Iā€™ve recently built SA5 Core and its centralized eventing system. Iā€™ll check this out to see if thereā€™s some type of accidental dependency on the existence of a userInfoChanged handler.

The documentation is definitely correct for the designed behavior. You read it right. This is why I put out the call for BETA testers, we always use the libraries with most of the features in use and wouldnā€™t have seen this configuration. Thanks for posting, thatā€™s exactly what we need.

Tip for the future, go back to the cloneable, Itā€™s tested and demonstrates a working setup for all features. Just clone, publish, and play. From there, you can easily adjust and test the configuration youā€™re trying to achieve.

A few notes-

5.3.4 includes access groups, which was merged in from BETA as the community has not reported any issues.

However, one key difference in access groups is the addition of the getMembershipConfig handler, which there appears to be a dependency on. Iā€™ve updated the docs accordingly;

Kudos for reporting that @nrtshort .

Adding a bit of clarification here as well;

Access groups doesnā€™t need to be ā€œactivatedā€, as itā€™s fundamental to Webflow User Accounts. As of 5.3.4, SA5 also support access groups in the main production lib.

However to make use of that feature, you need to do a bit of special setup;

Thank you for looking into this @memetican.

Iā€™m implementing SA5 at a time when Iā€™m learning Javascript by trial, error, and googling. Itā€™s good to know that Iā€™m getting far enough along that I can be helpful!