Sign Up button doesn't show up anymore with decorateWidget

Hello! It seems that the Sign Up button we had setup next to the Login button is no longer displaying and I see an error in the console saying “[THEME NAME] decorateWidget: Could not find widget ‘header-buttons’ in registry”

The way this button was added until now, as far as I’m aware, was via Customize → Themes with a script like this:


<script type="text/discourse-plugin" version='0.8.12'>
api.decorateWidget('header-buttons:after', function (helper) {
    if (!api.getCurrentUser()) {
        return helper.attach('link', {
            href: 'https://www.bassbuzz.com/account/signup',
            rawLabel: 'Sign Up',
            className: "btn btn-primary btn-small login-button"
        });
    }
});
</script>

I’ve read some similar topics like this Add button in header for logged in users - #3 by Lilly, but I always get the error of “header-icons” not found in registry.

I have also tried this and it’s the same result:

<script type="text/discourse-plugin" version='0.8.12'>
  api.decorateWidget('header-buttons:after', helper => {
    if (!api.getCurrentUser()) {
      return helper.h('li', [
        helper.h('a.btn.btn-primary.btn-small.login-button', { 
          href: 'https://www.bassbuzz.com/account/signup' 
        }, 'Sign Up')
      ]);
    }
  });
</script>

I also looked at the documentation here: Beginner's guide to developing Discourse Themes , but I can’t seem to figure out what I’m missing.

Is there a setting that might prevent the code above from functioning? It has worked before, not sure when it stopped working. Does anyone have any advice? Thank you in advance!

Hi @Andreea_Pomirleanu :wave: welcome to meta :slight_smile:

decorateWidget has been deprecated for Glimmer components. see here for info:

https://meta.discourse.org/t/upcoming-post-menu-changes-how-to-prepare-themes-and-plugins/341014

see below for the right link (thanks RGJ)

It’s in a different topic, Upcoming Header Changes - Preparing Themes and Plugins

1 Like