On my app, there are two users: Instructors and Students. Instructors can create their own course and sell it on the platform. Students will be able to pay for the course and have access to it forever. Right now, after purchasing the course…it unlocks the course for all other users. How do I lock it for only the current user that has paid for it?
If I need to send my app to somebody to check it out, I can.
You could create a Many to Many relationship between Users and Courses and after paying add Logged in user to that relationship property and you can make the link action link to the current course detail screen only when the current course>many to many relationship> contains>logged in user.
And you can add another screen to go if the user didn’t payed for that course. You can add a link action for that screen and add a condition only when current course>many to many relationship> does not contain> logged in user.
Thanks Dilon! This makes sense, but I guess I don’t know where to begin. Do I add another collection in the database, then create a new Current Course Detail screen? Or do I edit an action on a current screen? Not really sure how to create a relationship.
Something I have learned in the forums is to add true/false properties to users such as “havePaid”. So you can maybe add this as a condition using the “when does this happens?” → Sometimes when the Logged in user > havePaid is true.
Hey Luis, Thanks for your help. I previously had a list of the activities (courses) in the profile page filter “paid is true”, but that unlocked it for everybody if it was paid. I wonder if I need to filter it to be something else. I have a screenshot here as well.
If you filter the list like that the filter applies for every user. Instead of that filter you can add a visibility condition to the list that visible if Logged in user>Paid>is true.
When the user pay the all courses has to be visible and the user can access them all! Correct?
Then you don’t need a many to many to relationship in the Courses collection. Create a true/false property in the Users collection and name it as Paid? or something and after the payment add a Update Logged in user action that updates the true/false property to true ( In the action add True to that Paid true/false property ).
And you can add a visibility condition to the list clicking the three dots that Logged in user>Paid>is true.
The video shows if the user has to pay for each course. But you don’t need that because you need when the user pay show all courses!
Then you need a many to many relationship in the Courses table to store the paid users and then you can add a filter to the list that Users ( Many to Many relationship )>All>Contains>Logged in user.
You have a One to Many relationship between Users and Courses to store the instructor right?I guess you could add another Link action that link only when the Current course>Instructor>email>is equal to>Logged in user’s email. And put this action on top.