Add new item to user dropdown menu

How can I add a new item to the user dropdown menu? Can I personalize and add a new item there?

1 Like

Welcome to Meta :waving_hand:

You can use the plugin-API to add a new link to that menu. You can, for example, do that directly in the admin interface by creating a new theme component and adding something like this to the JS tab:

api.addQuickAccessProfileItem({
 icon: "pencil",
 href: "/somewhere",
 content: "Title"
})

2 Likes

Does this work in the horizon theme? I get an error in the browser

1 Like

Yes, sorry, I made a mistake when I copied the code.

By default, you see this in the JS tab.

import { apiInitializer } from "discourse/lib/api";

export default apiInitializer((api) => {
  // Your code here
});

And then, you put this where the placeholder is.

api.addQuickAccessProfileItem({
  icon: "pencil",
  href: "/somewhere",
  content: "Title"
})

So, the result should look like this:

import { apiInitializer } from "discourse/lib/api";

export default apiInitializer((api) => {
 api.addQuickAccessProfileItem({
  icon: "pencil",
  href: "/somewhere",
  content: "Title"
 })
});

Above, I had accidentally copied one of the default lines.

1 Like