How to lock access for users that did not pay for a program/course

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.

Hi DeJaun,

Welcome to the community :partying_face:

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.

Thank you

1 Like

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.

This would be my workaround

2 Likes

Your Welcome!

If it’s like 1 course then the method that @LuisNavarro posted is great! ( Thanks Luis! )


If it's more that 1 course the way that I posted is the way as far as I'm aware!

Made a video :

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?

Correct! I just added “Paid?” to the the Users database (I only had “paid?” to activities). I will try to follow the video now.

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!

Sorry about the confusion here lol but yes, the user has to pay for each course.

No Problem! :slightly_smiling_face:

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.

That seemed to work, I will try this on Testflight! Thanks Dilon…

Another question…the instructors are not able to access their own course via home screen. Is there another advanced action that will solve this?

1 Like

Your Welcome!

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.

image

1 Like

This worked as well! Thanks…will begin my testing.

2 Likes