Creating a gender limited forum?


(Eric Skiff) #1

I’m working with a entrepreneur to create a women’s only discourse forum. I’ve explored custom fields and have a gender option present during signup, but the ideal for this particular forum would be to only allow facebook signups and to pull gender from there.

I’m a rails developer so this seems accomplishable in abstract, but I’m not sure if the discourse plugin system has hooks into the Facebook login flow. Would something like this be possible? Where’s the best place to start learning about what plugins can and cant do?


(Vinoth Kannan) #2

You can find resources related to the plugin development here in Search results for '#howto plugin development' - Discourse Meta

In Discourse a plugin can do almost anything :sparkles:

Since you are only allowing signups from Facebook it is easier to implement this feature. We already saving gender value in facebook_user_infos table. Similar code like below can work for you (not yet tested)

after_initialize do

  FacebookUserInfo.class_eval do

    after_commit : add_to_gender_group, on: :create

    def add_to_gender_group
      return if gender.blank?

      group = Group.find_by name: gender.downcase
      group.add user
    end

  end

end

And you can limit all your categories only for “female” group.


Why so little code comment in Discourse Codebase? (Github)
(Eric Skiff) #3

Oh my gosh. This is beyond amazing. Years working on wordpress, and hundreds of integrations with APIs in rails, and I’ve never gotten “here’s what you need on a platter” assistance like this. You’re the best!

If I develop this plugin, can I use it on the official hosted discourse, or will I need to host my own?


(Jay Pfaffman) #4

Custom plugins require enterprise hosting. If you’d like help with self hosting, that’s what I do: Discourse Install self-host your own Civilized Discussion Community


#5

@pfaffman is one of the best.