Step 5. Check access to paid content
When determining if a user has access to specific paid content, you'll need to verify their access level. This means checking if the user has at least one access level, and if that level is the required one.
You can do this by looking at the user profile, which contains all available access levels.
Now, let’s allow users to purchase your product:
- Double-click the button that should show the paid content.
- Open the Actions section in the right pane if it’s not already open.
- Open the Action Flow Editor.
- In the Select Action Trigger window, choose On Tap.
- In the No Actions Created window, click the Add Conditional Action button.
- In the Actions Flow Editor window, choose Combine Conditions.
- In the Set Actions Arguments section, choose
currentProfile
variable. This is the Adapty variable that holds data about the current user's profile - Fill in the fields as follows:
Parameter | Value |
---|---|
Available Options | Data Structure Field |
Select Field | accessLevels |
Available Options | List Contains Items |
- Click UNSET.
- In the new Set Variable window, fill in the fields as follows:
Parameter | Value |
---|---|
Available Options | Data Structure Field |
Select Field | accessLevels |
Available Options | Is Set and Not Empty |
- Click the Confirm button.
- Click UNSET for the second condition.
- In the new Set Variable window, fill in the fields as follows:
Parameter | Value |
---|---|
Available Options | Data Structure Field |
Select Field | accessLevels |
List Index Options | First |
Available Options | Data Structure Field |
Select Field | accessLevels |
Available Options | Data Structure Field |
Select Field | isActive |
- Click the Confirm button twice.
Now, add the actions for what happens next — if the user has the right subscription or not. Either take them to the next page or show the paywall so they can buy access.