# 使用 decorateWidget 后，注册按钮不再显示

**URL:** <https://meta.discourse.org/t/sign-up-button-doesnt-show-up-anymore-with-decoratewidget/354691>\
**Category:** Support\
**Created:** [2025年二月26日 19:45 UTC](https://meta.discourse.org/t/sign-up-button-doesnt-show-up-anymore-with-decoratewidget/354691 "2025-02-26T19:45:57Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Andreea\_Pomirleanu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andreea_pomirleanu/32/485791_2.png) [@Andreea\_Pomirleanu](https://meta.discourse.org/u/Andreea_Pomirleanu)\
**Post date:** [2025年二月26日 19:45 UTC](https://meta.discourse.org/t/sign-up-button-doesnt-show-up-anymore-with-decoratewidget/354691/1 "2025-02-26T19:45:57Z")

</div>

您好！看起来我们之前设置在登录按钮旁边的注册按钮不再显示了，并且我在控制台中看到一个错误：“[THEME NAME] decorateWidget: Could not find widget ‘header-buttons’ in registry”。

据我所知，直到现在添加此按钮的方式是通过“自定义”-\>“主题”并使用类似以下的脚本：

```plaintext
<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>

```

我阅读了一些类似的主题，例如 [https://meta.discourse.org/t/add-button-in-header-for-logged-in-users/276704/3，但我总是收到“header-icons”在注册表中未找到的错误。](https://meta.discourse.org/t/add-button-in-header-for-logged-in-users/276704/3%EF%BC%8C%E4%BD%86%E6%88%91%E6%80%BB%E6%98%AF%E6%94%B6%E5%88%B0%E2%80%9Cheader-icons%E2%80%9D%E5%9C%A8%E6%B3%A8%E5%86%8C%E8%A1%A8%E4%B8%AD%E6%9C%AA%E6%89%BE%E5%88%B0%E7%9A%84%E9%94%99%E8%AF%AF%E3%80%82)

我也尝试过以下方法，结果相同：

```plaintext
<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>

```

我还查看了这里的文档：[https://meta.discourse.org/t/beginners-guide-to-developing-discourse-themes/93648，但我似乎无法弄清楚我缺少什么。](https://meta.discourse.org/t/beginners-guide-to-developing-discourse-themes/93648%EF%BC%8C%E4%BD%86%E6%88%91%E4%BC%BC%E4%B9%8E%E6%97%A0%E6%B3%95%E5%BC%84%E6%B8%85%E6%A5%9A%E6%88%91%E7%BC%BA%E5%B0%91%E4%BB%80%E4%B9%88%E3%80%82)

是否有任何设置可能阻止上述代码正常工作？它以前是有效的，我不确定是什么时候停止工作的。有人有什么建议吗？提前感谢！

---

_[View the full topic](https://meta.discourse.org/t/sign-up-button-doesnt-show-up-anymore-with-decoratewidget/354691)._
