Hello everyone, I want to know is it possible to expand/collapse sections based on user roles?


I have created three different user roles e.g. school, teacher, student. How can I display hide section for every visiting user? Any help would be great for me. Thanks in advance. : )

Set all the sections on collapsed, then this code will expand the sections depending on the role of the logged in member

//put the import at the top of the file
  import { currentMember } from 'wix-members';


//Put the code under this into onReady()
currentMember.getRoles()
  .then((roles) => {
for(let i = 0; i < roles.length; i++){
  switch(roles[i].title){
  case "School": 
    $w("#schoolSection").expand()
    break;
  case "Teacher": 
    $w("#teacherSection").expand()
  }
  case "Student":
    $w("#studentSection").expand()
}
    return roles;
  })
  .catch((error) => {
    console.error(error);
  });