Help on redirect user on gated content

Continuing the discussion from Gated Topics in Category:

I was trying to modify the gated component to redirect the user to a specific page instead of showing a gate

1
I tried DiscourseURL.routeTo('/t/table-builder-test-2/1667') on theme creator, it works but takes a while and throws errors on loading, although the page is successfully loaded.

2
I also tried with setDefaultHomepage('/t/table-builder-test-2/1667'); and

      const container = Discourse.__container__;
      const router = container.lookup("router:main");

      let topicId = router.currentRoute.parent.params.id

      PreloadStore.remove(`topic/${topicId}`);

It only redirects after the gated page is loaded then click on the back button.

3
location.href = '/t/table-builder-test-2/1667'

It works but the gated pages also loaded for a few secs, unlike 1 do it smoothly.

What is the best way to achieve this?

My Custom Homepage theme changes the home page. The trick is that some stuff gets preloaded and you have to do something to make it go away.

Hopefully you can find the example in the code, as that’s the best I can explain it from my phone. :person_shrugging:

1 Like

I tried with

let topicId = router.currentRoute.parent.params.id
PreloadStore.remove(`topic/${topicId}`);

but it doesn’t work, do we have a document about how the PreloadStore.remove method works?