Creating a gender limited forum?

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?

1 Like

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.

9 Likes

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?

10 Likes

Custom plugins require enterprise hosting. If you’d like help with self hosting, that’s what I do: $99 Discourse Install – Literate Computing, LLC

5 Likes

@pfaffman is one of the best.

4 Likes