Adding a button for unauthorized members


(Evgeny) #1

I tried to add this button only for unregistered users. Make it visible, when you click on that, the transition goes to the registration page.

<script type="text/discourse-plugin" version="0.2">
let currentUser = api.getCurrentUser();
if (currentUser) {
} else {
    
    api.decorateWidget('header:after', helper => {
        const showExtraInfo = helper.attrs.topic;
            if(!showExtraInfo) {
                return helper.h('div.wrap.list-contr', [
                    helper.h('a#create-topic.btn', {
                        href:'https://***/login', 
                        text:'+ ADD***'
                    })
                ]);
            }
    });
    }
    </script>

    .wrap.list-contr {
        padding-top: N*px;
    }

All styles of css can be easily changed.

I want to try to see how the number of registrations behaves. Without pre-pop-up windows that can annoy users.
The window pops up, but only after clicking.

Is the code correct? Can be something to correct?

The button is disabled in the mobile version, because this is a special case.