I’ve a client that wants to add a link to a user profile for members of a particular group.
I thought about the signature plugin, but I’m wondering whether it might be possible with a theme component.
Is there some way that in the :after of a post members of a certain group could have I'm great, see my [profile](https://site/u/username) in a theme component?
It could be done in a theme component with api.decorateWidget if the information you need about the user is available in the helper.attrs property that is passed to the function. This will work if the group you are looking for is the user’s primary_group.
It can take a bit of messing around to find the right widget and type. The easiest way to do that is to look through the source code. Searching for applyDecorators in the widget files lets you know what types are available. The following works, but you should test it. Do a console.log on the attrs variable to see what is available to you. It will take a bit of CSS to get it to look good.
<script type="text/discourse-plugin" version="0.8.25">
api.decorateWidget('post-contents:after-cooked', helper => {
let h = helper.h,
attrs = helper.attrs;
if (attrs.primary_group_name === 'your_primary_group_name') {
return h('div.group-signature', h('a.group-user-link',
{ href: '/u/' + helper.attrs.username }, 'See my profile!'));
}
});
</script>