Code is now broken? | Memberships & Current User Info

Hey, so this code we had to display different content for different users is now broken. I can’t find any documentation on how to fix it with the updated version?

<!-- Sygnal Attr | User Info -->
<script type="module">
import { WfuUserInfo, WfuUser } from 'https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@4.7/src/modules/webflow-membership.js'; 
import { WfuDataBinder } from 'https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@4.7/src/modules/webflow-databind.min.js'; 

$(function() {
  var membership = new WfuUserInfo({
    userInfoUpdatedCallback: myCallback
  }).init(); 
});  

async function myCallback(user) {
  // Automatic data-binding using attributes
  var accessGroup = user.data["group"]; // Get the value from the user object

var elements = document.getElementsByClassName(accessGroup); // Select elements with the same class
for (var i = 0; i < elements.length; i++) {
  elements[i].style.display = 'flex'; // Set the display style of the elements to 'flex'
};
  
  var employeeGroup = user.data["employee"]; // Get the value from the user object

var elements = document.getElementsByClassName(employeeGroup); // Select elements with the same class
for (var i = 0; i < elements.length; i++) {
  elements[i].style.display = 'flex'; // Set the display style of the elements to 'flex'
};
  
  var dataBinder = new WfuDataBinder({
    user: user
  }).bind(); 
} 
</script>

I have tried updating the source links to:

https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@5.2.18/src/modules/webflow-membership.js
https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@5.2.18/src/modules/webflow-databind.min.js

But this did not fix the issue.

unfortunately it’s not something easily viewable on the front end of the site since certain content should be showing when a specific user is logged in. It is displaying the same content when a user is logged out as when a user is logged in.

https://habinternal.webflow.io/

Trying this…

<!-- Sygnal Attr | User Info -->
<script type="module">
import { WfuUserInfo, WfuUser, WFUDataBinder } from 'https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@5.2.18/dist/nocode/webflow-membership.js'; 

$(function() {
  var membership = new WfuUserInfo({
    userInfoUpdatedCallback: myCallback
  }).init(); 
});  

async function myCallback(user) {
  // Automatic data-binding using attributes
  var accessGroup = user.data["group"]; // Get the value from the user object

var elements = document.getElementsByClassName(accessGroup); // Select elements with the same class
for (var i = 0; i < elements.length; i++) {
  elements[i].style.display = 'flex'; // Set the display style of the elements to 'flex'
};
  
  var employeeGroup = user.data["employee"]; // Get the value from the user object

var elements = document.getElementsByClassName(employeeGroup); // Select elements with the same class
for (var i = 0; i < elements.length; i++) {
  elements[i].style.display = 'flex'; // Set the display style of the elements to 'flex'
};
  
  var dataBinder = new WfuDataBinder({
    user: user
  }).bind(); 
} 
</script>

Hey Dani,

First, the new updates for V5 do not affect anything you were running previously.
However it’s good to update if you can, as there are some nice improvements.

Second, in V5 the setup is entirely different. See the docs for the new setup code.

There are a bunch of differences.

  • Code is moved to before HEAD for better performance
  • No modules
  • No jQuery
  • No more databind library reference
  • Entirely different setup and callback

Looks like you’re trying to mix a bunch of things together. What you have in that above code won’t work at all.