Redirect all users who click on domain.com/signup to a different page


(Johnathan Nader) #1

I’m currently trying to redirect all potential new users to a landing page instead of having the modal show up. What would be the most elegant way to do this? If they sign up I would create their account via the API


(Vinoth Kannan) #2

You can use SSO login


(Johnathan Nader) #3

Right, but I feel that’s just too complicated. I simply want to just not have anything change on the site and simply redirect all those who want to sign up to a different page as I still want them to be able to log in and not have the css change or trying to add in another login button


(Vinoth Kannan) #4

No, you can’t do it without a plugin / theme customization.


(Johnathan Nader) #6

If I was to make this a plugin could I do something like this, and not even need the javascript just with the plugin.rb?

# name: signup
# about: /signup plugin for Discourse
# version: 0.1
# authors: nadermx


after_initialize do
  Discourse::Application.routes.prepend do
    get 'signup' => '//newdomain.com'
  end
end

(Vinoth Kannan) #7

Signup button click won’t call server route to navigate like your plugin example. It will just display the ember popup in browser.

So you only need a custom signup link via theme customisation.


(Johnathan Nader) #8

In permalinks? I tried setting up a permalink for signup to a extarnal link called new.domain.com/ but it still just shows the sign up modal


(Vinoth Kannan) #9

When the signup button clicked nothing else will happen except displaying the popup. So you have to change the behaviour of the button or replace it with a link.


(Johnathan Nader) #10

Right, I’m trying to replace all the /signup links on the button and in the login

I’m just confused as to what is the best way to do this? You suggested making a plugin, but now you are suggesting replace the link.

This is what I’m trying to do but still a bit confused


(Vinoth Kannan) #11

I suggested you for plugin / theme customisation. It is possible in both ways. But creating a custom rails route won’t help.


(Johnathan Nader) #12

Alright, I’m trying to edit the theme instead and have put this javascript in my </head> section

<script>
    document.getElementsByClassName(".sign-up-button").onclick = function () {
        console.log('this should print');
    };
</script>

But when ever I click it it does not show in the console.

I’ve also tried variations, it does show the element but no actions of the js are working on it such as

<script>
    var thingy = document.getElementsByClassName("sign-up-button");
    console.log(thingy);
    thingy.onclick ="return false;"
    thingy.onclick = function() {
        window.location.href = "https://join.example.com";
    };
    console.log(thingy);
</script>

(Johnathan Nader) #13

I still can’t seem to get this to work as it seems even if I put the script in the </body> of the admin pane, it still always shows the length as 0 of the html collection. I suppose it’s because it’s firing before the document is fully loaded?

<script>
    var thingy = document.getElementsByClassName("sign-up-button");
    console.log(thingy.length)
    for (var i = 0; i < thingy.length; i++) {
            console.log('pring this');
    };
</script>

Any help would be apprecicated