I have a ‘Get started’ page (with a form) that users are directed to after sign up. However, they can bypass the form on this page by going to the root URL (home).
Is there a way to automatically redirect them to the Get started page as long as they haven’t completed the form?
If, in your database, in the users table, you have a field that would let the system knows that a logged in user has not filled out the form yet, then it’s doable.
Do you have such field?
You can also create a user group (let’s say “onboarding form not filled out”) and create a dedicated block for this user group, in the homepage, to let them know they have to go to the form page.
Okay, so let me know what is the field name (case sensitive) and I give you the script to add.
This field should be in the users table (sorry for repeating but that’s important ).
If you need it to be applied to all pages then you should insert it at app level => custom code header and change the script like this:
Here the script will be triggered on every page of your app, for a logged in user who has not filled out the form yet, except in the page /get-started (otherwise there would be an infinite loop)
<script>
document.addEventListener('DOMContentLoaded', function() {
if (window.location.pathname !== '/get-started' && window['logged_in_user'] && !window['logged_in_user']['Is in Softr']) {
window.location.replace("/get-started");
}
});
</script>
Careful this will also affect utility pages so you would need to exclude them.
So the script should be, if I take the example of excluding the account settings page in addition:
The issue was that the signup page automatically added “?next-page=/” to the URL. Which stopped the page rules redirect. The Softr support team fixed it on their end.
About your solution. It almost works but there is a new issue. When the user first passes the onboarding, they are redirected to the home page. I think the {Is in Softr} field is getting updated after that redirect. Which causes your script to redirect the user back to the Get started page.
To clarify, the delay happens because we need to run an automation in Airtable to merge the old user record with the new one submitted by the onboarding form. Because the form doesn’t normally target the user record.
Ok, could you try, instead of directly redirect them to the homepage with your conditional form one of these options:
show a thank you screen with a button “go to homepage” – so no direct redirection
or create an intermediate page with a url /onboarded-success where the users would just click a cta button (with a label like “go to the homepage” or something else) - might be the best solution
If option 2, you would need to update the script this way:
Yes and no .
I can check if a user is in a user group… by replicating the user group conditions in the script.
Basically, right now it’s impossible to directly reference a user group in a script unless the script reproduces the conditions of the user group (in your case I guess the user group would have the condition “is in softr” is checked => so it wouldn’t change anything).
Please try option 2, it might work.
If not Here is the original script with a 3 seconds delay.
You can play with these 3 seconds by changing “3000” (milliseconds) by 2000, 4000…