Restrict member page access

Hi Guys,

I’m currently a part of wix code beta, on wix I am able to create member groups for people who have become a member of my site… I want to grant specific member groups access to specific pages, depending on what learning course they have signed up to… is this possible to do or not?

Hi Nat,
Yes, you can do it using the JavaScript features in Wix Code.
The exact approach would depend on your logic and collections, but here are some tools to point you in the right direction:

  • Use currentUser to get the currently logged in user, and their role

  • Option I - When the page loads, use this to determine whether the user should have access and navigate to a different page, or show a message. This is an easier approach than the next one, but you might want to do it even sooner in the process…

  • Option II - Use a Custom Router . A custom router is basically a way to run your own custom JavaScript to control the routing from URL to a page. So you could hook up a custom router to yoursite.com/ courses /xxxxxxx and check access in there. If the user doesn’t have access return a 403 (restricted) response, or redirect them to the homepage or something.

Hi, I need to do something similar. I have an online course and open new sections each week after the user registered. I have a wordpress site right now and use the S2Member code:
[s2Drip access=“level0” from_day=“7”]
(code means: If the user has been registered over 7 days, show this content)
[/s2Drip]

Anyone know of something similar I can use in Wix?
Thanks!