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 | Filter List Items |
Filter Conditions | Conditions -> Single Condition |
-
In the Filter Conditions field, click UNSET.
-
In the Set Variable window, click Conditions -> Single Condition.
-
In the new Set Variable window, click UNSET next to First value.
Parameter | Value |
---|---|
First Value | Item in List |
Available Options | Data Structure Field |
Select Field | accessLevelIdentifier |
-
Click Confirm.
-
In the Set Variable window, click UNSET next to Second value.
-
In the Value field, enter the ID of your access level, in our example we use
premium
. -
Click Confirm.
-
In the new Set Variable window where you returned, fill in the fields as follows:
Parameter | Value |
---|---|
Available Options | Item as Index |
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.