Trying to show self replies in color

You can do this by adding the following code to the Header of your theme (or to the header of a theme component):

<script type="text/discourse-plugin" version="0.8">
    const currentUser = api.getCurrentUser();
    api.addPostClassesCallback((attrs) => {
        if (currentUser && currentUser.id === attrs.user_id) {
            return ["post-by-current-user"];
        } else {
            return [];
        }
    });
</script>

You can then use the post-by-current-user class in your stylesheet.

11 Likes