How can I automate the role assignment for new members?

I’m having trouble with
setting up the automation of one of my e-commerce flows. I would like to assign new members / customers a role, so that they get automated access to certain member sites.

Working in
WIX Studio Editor

What I’m trying to do
So, I would like to automate the access to certain member sites. I have different member sites that contain different virtual courses. Not all members are allowed to have access to all member sites. Therefore I’ve created roles (e.g Course 1, Course 2, Course 3). Now I would like to automate the role assignment, when a customer purchases a course.

I’ve set the trigger to WIX Stores and then a rule to the article number. Next I would like to define the Action which is: Assigne Role to Member/User. But this is not an option in the WIX Automation section… Can someone help and let me know, how I can automate this process?

Extra context
E.g. Customer 1 purchases Course 2. He will get a digital product with a link to the member page. He needs to log in. He is only allowed to see Course 2. Currently, he sees Course 1, Course 2 and Course 3 and could access all of them.

I would prefer that when customer purchases e.g. course 2, he gets the digital product with the link to the course, and when he clicks on the link, he immediately has access - I don’t always have the time to immediately assign the roles manually.

Thanks so much for your help

The workaround is to use custom code. Wix has a backend assignRole() function for assigning roles to members, and Wix Stores has an onOrderPaid() backend event that runs when a store order is paid.

So the flow would be:

Customer buys Course 2 → Wix Stores order is paid → backend event checks the purchased SKU/article number → assigns the matching member role → the Course 2 member page becomes available.

The important catch is that the customer needs to be a site member. If they check out as a guest and are not logged in / registered, Wix may not have a member ID to assign the role to. Ideally, make customers log in or sign up before purchasing the course.