Forum Academy Marketplace Showcase Pricing Features

Restrict access to certain data and change element property according to user age

I’m trying to prevent users below the age of 18 from viewing adult content in a video streaming web app.

I already know how to get the age through a formula I got from another post. Now my question is, how do I prevent my repeating group from showing content for adults if the current user is below 18?

In my data type called “movie”, I have a field called genre, and if a certain movie’s genre is “adult”, I want the repeating group to exclude that if the current user is below 18.

Also, I have a dropdown that allows users to filter movies by genre, as shown in the screenshot below:

As you can see, these are just static choices and I would like to leave it at that for now.
How do I prevent the app from showing the adult option if the user is below 18?

I figured I’d have to add a workflow that starts with “when a page is loaded”, but adding conditions it’s still a little vague for me, as I’m new to Bubble.

I’ll appreciate any help that is given to me.

I would have a field on the user that is ‘User_is_over_18’ That will be a checkbox and is a one way street.

Now your content will need to have a field that is ‘Not_suitable_for_U18’.

When you run the search for the repeating group, you now use these states to determine whether adult content is filtered from the search.

1 Like

What do you mean checkbox? Do you mean ‘User_is_over_18’ is a “yes/no” field type?
And if I make it that way, how do I make the program automatically set its value based on a user’s date of birth?

I think I got what you mean by this part. What you meant was add a conditional in the repeating group and the dropdown.

You should use a daily backend workflow to search for users who are 18 by date and User_us_over_18 = no and update that record.

1 Like

For the sake of everyone reading, I’d like to share how I was able to accomplish what I wanted to happen in the app:

So as nfisher mentioned, I added another field on the user called ‘User_is_over_18’, with a yes/no field type and a default value of “yes”.

Updating this value to a no happens when the user logs in and navigates to the homepage, as seen in the screenshot below:

Also, when the app finds out that the user is below 18 via the field type mentioned earlier, a conditional in both dropdown and repeating group filters the data source being used on those two elements:

This post is henceforth solved.