Redirect Users Only to a Particular Page


I’m starting my redirect file therefore need code for directing “users who have confirmed their email to my online-terms-and-conditions.html file” only.

@MM6th I’m not entirely clear on what you’re trying to do, but the Netlify redirects system couldn’t possibly have any awareness of “if a user has confirmed their email address”.

If you have a particular unique url that those users would be coming in via, then you could redirect that to the terms and conditions, is that what you mean?


/email-confirmed    /online-terms-and-conditions    301

Oh! The email has been confirmed now. It didn’t initially work because I had the settings on invite only (learned that in the forum, thanks). Once I changed it the emails began confirming, so now what I want to do is send users who once they press the login button after their information is inserted, to take them to my terms and conditions page rather than stay on the index page where they logged in.

Is this email generated upon registering for the site?

Are you wanting to direct them to the T&C page after acknowledging the email confirmation? If so, you have to create a custom email template with the link to the T&C page. Here’s some information about the custom confirmation email templates.

Also, I think you will have to put the Identity widget on the T&C page as well to make this work.

1 Like

Can I establish this by still using netlify only? Also, does the widget have to go on the t&c page as well so that they can log out?

I’m not sure what you mean about email being generated from registering to the site. All I know so far is that the email is confirmed, and in my identity tab in netlify I’m able to assign the email a role

I would believe this is possible with just Netlify. The Netlify Identity default emails automatically take you back to the index page. In order to have users go to any other page you must use custom email confirmation templates. For example, for my website, my sign up and log in pages are not on the site homepage (i.e, index page) so I had to customize my emails (using the documents I linked to in previous response). And per those guides, yes you must have the widget on the same page that you link out to.

What I meant is that you intend this re-direction to be used for new users, right?

So: a new user signs up for your site with the Identity widget. The user gets notification that an email has been sent to them. User goes to inbox, opens confirmation email. Now, I’m assuming that you want that newly registered user to read that email in their inbox, then click on the confirmation link and you want them to be directed from that email to the T&C page–not to the homepage or where you originally had them sign up. Is that correct? That’s what that guide addresses.

Or are you trying to redirect existing users to the T&C page every time they log in?

I’m trying to redirect existing users to the T&C page every time they log in. At least for now.

In that case, I think what you need to do is trigger a function call when users log in. That entails creating a function file so that when a user logs in, that log-in event triggers a call to that function file. Note that that function file would have to be named as the function call. In your case: identity-login.js. That file will require code to direct people to your site. I’m not sure how simple the code in that file will be (assuming it will be javascript though) as I’ve not tried this myself.

You’ll need to read through this to start:

Good luck! Also, somebody may have a different/simpler solution.

Thank you for this. I will look into this as well as remaining open minded to someone else’s approach.