Page Rules
Transcript Summary
Introduction
What's up, databaser? Sam here. In this video, I'm going to teach you all about page rules.
What Are Page Rules?
Page rules are rules that run before loading a page to check if the page should load or not. You can specify different actions and conditions for these page rules.
Rule Options
- Show a message instead of loading the page.
- Redirect to another page instead of loading the current page.
- Redirect to a URL (another website).
- On details or child pages, you can redirect to a parent page based on the conditions you specify.
Example: Displaying a Message for Inactive Users
Let's set up a sample page to show you how page rules work. In this case, we want to display a message to users who are inactive.
- We create a new rule to show a message.
- The condition is based on the logged-in user’s status. If the status is inactive, instead of loading the page, a message will be shown saying, "You are not authorized to access this page. Please contact your administrator to activate your account."
- You can format the message using HTML and set its style, such as a danger or error message.
Conditions Setup
- Logged-in user status: Choose "is not active" to show the message if the user is inactive.
- This prevents users with inactive status from accessing the page.
Testing the Rule
I logged in as a user who is inactive, and when trying to load the page, the message is displayed, blocking access.
Redirecting to a Profile Page
Now, let's set up another page rule that redirects users to their profile page if they are missing certain information (e.g., email or phone number).
- Create a rule to redirect to an existing page.
- The condition checks if the user's email field is blank.
- If the email is missing, users are redirected to the profile page to update their information.
You can choose any page within your app for the redirection.
Redirecting to a Custom URL
Another option for page rules is redirecting to an external URL. For example, if you're integrating with Stripe, you can redirect users to the Stripe payment page if their subscription is inactive.
Example
You could check if a subscription is active using a custom condition, and if not, redirect the user to a payment page.
More Advanced Page Rules for Details Pages
When working with details pages (child pages), you have more options for page rules:
- Redirect to a parent page.
- Access fields from the parent page's data table in addition to the logged-in user's data.
Example: HIPAA Compliance
Imagine an app that handles medical data. Some users have completed HIPAA training, and some haven’t. We store this information in the user's table.
- If the user hasn't completed the HIPAA training and the record contains protected health information (PHI), we redirect them back to the parent page.
- To set this up, we create a rule that checks if the record contains PHI and if the user hasn’t completed training. If both conditions are true, the user is blocked and redirected.
Setting the Conditions
- Contains PHI info: Yes.
- User completed HIPAA training: No.
- If both conditions are met, the user is redirected to the parent page.
Broader Condition Setup
Instead of checking for a specific value like "no" for the training, we can broaden the condition by checking if the user’s training status is not "yes." This ensures the rule applies even if the value is blank.
Page Rules as Security
Page rules provide an additional layer of security, allowing you to get more granular with permissions. You can control access to specific pages based on various conditions, even targeting specific users.
Conclusion
I hope this gave you a good understanding of page rules. You can use them to:
- Show messages.
- Redirect users to other pages or external URLs.
- Block access to certain users based on specific conditions.
- Get even more granular with security on details pages by using data from parent records.
Thank you for watching, and I hope this was helpful!
We'd love to hear your feedback.