Add a Sign up button (memberful purchase link) in header and disappear when log in

A note for future readers.

The approach mentioned by @dax works fine, however another approach you can take to add a Sign Up button when SSO is active is to use the plugin api in a header script.

The advantage of using the plugin api is that you can insert the button in the right part of the DOM tree to make styling easier.

This issue arose in the context of getting @Francois_Douville’s button to play nicely with the Header Search Theme (see here).

In @Francois_Douville’s case, the appropriate javascript to add the button is:

<script type="text/discourse-plugin" version='0.8.12'>
api.decorateWidget('header-buttons:before', function (helper) {
    if (!api.getCurrentUser()) {
        let rawLabel = helper.widget.site.mobileView ? "S'inscrire" : "S'inscrire gratuitement";
        return helper.attach('link', {
            href: 'https://lepeuplier.memberful.com/checkout?plan=27167',
            rawLabel,
            className: "btn btn-primary btn-small login-button"
        });
    }
});
</script>
5 Likes