You’re correct that this code is now outdated because we replaced the widget system. Here’s some information about that from last year: Upcoming post stream changes - How to prepare themes and plugins .
It is still possible to get this to work, but you’ll have to use a Glimmer Component. It could look something like this:
import Component from "@glimmer/component";
import { apiInitializer } from "discourse/lib/api";
class UserFieldBadge extends Component {
static shouldRender(args) {
return !!args.post?.user_custom_fields?.user_field_4;
}
<template>
<span class="poster-user-field">
{{@post.user_custom_fields.user_field_4}}
</span>
</template>
}
export default apiInitializer((api) => {
api.renderAfterWrapperOutlet("post-meta-data-poster-name", UserFieldBadge);
});
Remember that you’ll need to match user_field_4 in this code to the actual field you want to show.
I’ll leave it to others to modify this so that it can show ALL the public user custom fields. ![]()