Page Permissions(Solved)

Hi, I have a site thats sells language lessons.
The lessons are for members only and members have to pay a subscription fee.
Now everything works just fine except that Im having troubles with setting the lesson pages permissions.
In this page below you can see all the lessons.
Each one of the Images is linked to a lesson.


Now when a user clicks on a lesson I want:

  1. First, when a user pays for subscription his ID and his Email are inserted to a “Paid members” collection.
  2. Then I added a code that checks if the current user is logged in as a member.
    This is the code I wrote:

  1. If the user is logged in, I want to run a query that checks if the currrent user ID and Email are exists in the “Paid members” collection.
    4)If the user exists in the collection I want him to be redirected to the lesson he clicked on. If he dosen’t exist I want to show a lightbox that says that this is a member only content.

For now with this code the query doesn’t seem to work.

I would really appreciate if you could help me with setting this up.

Thanks!

Hey there,
It seems that you are not using the query right. You search for an item that its “_id” is equal to its “_email”.


Have a look at this article : https://www.wix.com/code/reference/wix-data.html#query

Good luck :slight_smile:

Hi, thank for your help.
So I read the article you posted but still didnt understand how Im defining a query that looks for an Id Email match.
Can you tell me in general what should I put instead?
Thanks

Hi, when you use query you search for an item that has a specific value in a specific field.
The id is not necessary in this case, you can search for the user email in the email field.
In this picture you can see the meaning of the “_id” (a unique text for each row that is usually used for updating data):

Your welcome!

So I changed the query to .eq only for “Email” and userEmail, and yesterday it seems to work,but now stil something is not working.I tried to add few email addresses and then connect as a user with each email and to see how the page reactes but looks like its not looking for a match because its not giving the access even while the current member email is exists undr the field “Email” in the collection.

Thanks again really appreciate you help!

Hi,
It seems like the userEmail has no value, in this case the query won’t work.


You should set it to the cuurent user’s email. Further more send the site URL.

Hi, thanks for replay.
You right, that was actually the problem, I already fixed it now it works just fine :slight_smile:
Thanks!