Is it possible to have the "Sign Up" button persist during scroll, rather than the "Log In" one?

Most people scrolling down a thread on my site will not have yet signed up.

Thus I’d like them to see the “Sign Up” button when they’re in a thread, rather than the “Log In” button. (even though I know it’s possible to sign up using either button, the “Sign Up” one is more obvious).

Anyone know if that’s possible?

Some (small? medium?) percentage of readers may not realize that there’s a Sign Up button while scrolling, and I’d rather make it super obvious to them. And I figure that those with existing forum accounts would be much more likely to have seen the Log In button before, so the persistance of the Log In button is relatively less useful for them than the persistance of the Sign Up button would be for those without accounts.

3 Likes

Not sure if bumping is okay, but anybody happen to know if the above is possible?

It is possible, here’s one way to do it.

You’re essentially replacing our default header-buttons widget and moving !attrs.topic. You can add this to a theme in the header section (admin > customize > themes > edit CSS/HTML).

<script type="text/discourse-plugin" version="0.8.13">
api.reopenWidget("header-buttons", {
      tagName: "span.header-buttons",

  html(attrs) {
    if (this.currentUser) {
      return;
    }

    const buttons = [];

    if (attrs.canSignUp) {
      buttons.push(
        this.attach("button", {
          label: "sign_up",
          className: "btn-primary btn-small sign-up-button",
          action: "showCreateAccount"
        })
      );
    }

    if (!attrs.topic) {
    buttons.push(
      this.attach("button", {
        label: "log_in",
        className: "btn-primary btn-small login-button",
        action: "showLogin",
        icon: "user"
      })
    );
    }
    
    return buttons;
  }
});
</script>

8 Likes

Thanks! You are indeed awesome.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.