Members Area Menu

Hi!

I have created a members area and included a new menu which links to various pages on the site.

On two of these pages, I have content that needs to change based upon which user is logged in and their role in member permissions.

Does anyone know of a way to either change the content displayed based upon the user (in this case, a google calendar and dropbox folder) or change the two menu links so each user gets sent to a different page depending on their role.

(Screen shot of member menu below)

Thanks!

Hi @richhurley ,

I recommend tailoring the content on the Wix Member Pages depending on the role of the currently logged in user.

You can accomplish this by creating a backend function that uses getRoles() to return what type of user is currently logged in.

Then, you can call this on the Wix Member Page Code and accordingly show relevant content according to the type of user.

Is there a better tutorial on how to do this? I have 2 different types of members that I want to have two different menus for.

  1. First of all you will have to create one ore more ROLES in the DASHBOARD of your Wix-Site.

Doing this, you will get back your ROLE(s) ID(s).
You will need this ROLE-ID later.

  1. After you have created your roles and after you got your ROLE-ID, the second step will be to get the MEMBER-ID of the member you want to assign the wished ROLE.

Lets say you got your 2-ingridients…something like…

const roleID = "b62310c1-1c81-4ca9...";
const memberID = "72751428-2743-4b...";
  1. You will have to work at BACKEND, because assigning roles only works on backend, thisfore you will have to create a new JSW-Module/File.

You can name however you want, lets call it MEMBERS.jsw. You have now generated a BACKEND-MODULE, which will be needed to proceed.

Writing the BACKEND-CODE:

import { authorization } from 'wix-members-backend';

export function myAssignRoleFunction(roleID,memberID){
    const roleID = "b62310c1-1c81-4ca9...";
    const memberID = "72751428-2743-4b...";

    const options = {suppressAuth: false}; //true ???

    return authorization.assignRole(roleID, memberID, options)
    .then(()=>{
        console.log("Role assigned to member")
    ;})
    .catch((error) => {console.error(error);});
}
  1. Now import your backend-function to front-end and start it…
import { myAssignRoleFunction } from 'MEMBERS.jsw';

$w.onReady(async function() {
    myAssignRoleFunction()
    .then((res)=>{console.log(res);})
    .catch((err)=>{console.log(err)});
});

Of course this code is expandable and has to be modified to get your wished working function.

Monitor the CONSOLE, to see RESULTS.

Following this link, you will learn surely more about this topic…