Create plugin for user profile

(M Zain Damlag) #1

Is there any tutorial how to create a plugin that create user profile like facebook and whatsapp where user can post updates to his profile or other users profiles. or can you help me with the following:

1- Create new database tables and set new model relations.
2- Add new code to User profile as New page with new tab beside (Activity - Notification - Badges …etc)
3- Use the default discourse editor that creates topics to create the updates in user’s profile.
4- Change the default tab where user access his profile.
5- Create a Notification for users.

(James Kiesel) #2

That seems like a beast of a plugin, something which would take an experienced dev at least a couple months to churn out to satisfaction. Is there a minimum viable solution (something like ‘allowing the user to post a ‘current status’ on their profile’), that would fit your use case?

(M Zain Damlag) #3

I know it’s takes a lot of time, I can do this through rails or by editing discourse source code but I want to convert my changes into plugins to not stick with one version of rails code and refactor my code with discourse changes.

The most important thing I want to know how do these points through plugin not editing discourse code, specially point 1 and 3.

(Rafael dos Santos Silva) #4

Don’t. Use either:

  • Custom Fields (Posts, Topics, Users)
  • PluginStore
  • Existing fields (like babble use hidden topics)

This is easy, just call d-editor on the handlebars template :slightly_smiling:

(M Zain Damlag) #5

First thanks you for your reply, Second I wanna ask about:

The user will have many posts and these posts may be a text, image or link so It can’t be custom fields I think.

Is there a tutorial or documentation for how to use “PluginStore” or “Hidden Topics”

(James Kiesel) #6

I think using hidden topics similar to how Babble does it would be the best way to go for creating somewhat complicated posts with content (That’s pretty much the core competency of Discourse, so rewriting it is probably Not The Best™)

This would involve creating a hidden topic for each user, and making that his/her ‘wall’, which they or other users can post to similar to a normal topic.

Of particular interest might be the Babble::Topic class, which is handling the creating of hidden chat topics.

(M Zain Damlag) #7

@gdpelican So with the same way I can create hidden category called wall for example and in each user will have a subcategory for all his wall posts and each update he post or any user will be a topic in this subcategory? And btw I were reading your plugin code while you replied.

But according to the second point of inserting this in new tab in users profile is there are plugin-outlet s that I can use to do this?

(Jafeth Díaz Castañeda) #8

Hello @gdpelican,

I have been reading babble’s code and I don’t see that the visible field of the topics is being set to false. However, the topics are unlisted and the posts don’t appear in the users’ profiles. I suspect that it has to do with the fact that the topics are owned by the system user, but I’m not sure.

Could you go into detail about how babble is accomplishing that?


(James Kiesel) #9

We used to do it the way you describe, but now I’ve tapped into the TopicQuery class to filter out topics with the archetype ‘chat’:

class ::TopicQuery
  def default_results
    super.where('archetype <> ?', 

(default_results is called pretty much whenever a list of topics is requested)

I do a similar thing in the UserSummary class to filter out chat content:

class ::UserSummary
  def topics
    super.where('topics.archetype <> ?',

  def replies
    super.where('topics.archetype <> ?',

  def links
    super.where('topics.archetype <> ?',