diff --git a/app/assets/javascripts/discourse/models/user.js b/app/assets/javascripts/discourse/models/user.js
index 0a651c01aba..c679c9e1955 100644
--- a/app/assets/javascripts/discourse/models/user.js
+++ b/app/assets/javascripts/discourse/models/user.js
@@ -288,6 +288,11 @@ Discourse.User = Discourse.Model.extend({
}));
}
+ if (!Em.isEmpty(json.user.custom_groups)) {
+ json.user.custom_groups = json.user.custom_groups.map(function (g) {
+ return Discourse.Group.create(g);
+ });
+ }
if (json.user.invited_by) {
json.user.invited_by = Discourse.User.create(json.user.invited_by);
}
diff --git a/app/assets/javascripts/discourse/templates/user/user.js.handlebars b/app/assets/javascripts/discourse/templates/user/user.js.handlebars
index f781ff707ec..05feafb5098 100644
--- a/app/assets/javascripts/discourse/templates/user/user.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/user/user.js.handlebars
@@ -43,6 +43,14 @@
{{{bio_cooked}}}
+ {{#if custom_groups}}
+
+ {{#each custom_groups}}
+ {{#link-to 'group' this}}{{name}}{{/link-to}}
+ {{/each}}
+
+ {{/if}}
+
{{#if isSuspended}}
diff --git a/app/models/user.rb b/app/models/user.rb
index 3d730bfd540..540a320806f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -98,6 +98,10 @@ class User < ActiveRecord::Base
3..15
end
+ def custom_groups
+ groups.where(automatic: false)
+ end
+
def self.username_available?(username)
lower = username.downcase
User.where(username_lower: lower).blank?
diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb
index 411e306a0ab..7d93ffee7cd 100644
--- a/app/serializers/user_serializer.rb
+++ b/app/serializers/user_serializer.rb
@@ -22,6 +22,7 @@ class UserSerializer < BasicUserSerializer
:suspended_till
has_one :invited_by, embed: :object, serializer: BasicUserSerializer
+ has_many :custom_groups, embed: :object, serializer: BasicGroupSerializer
def self.private_attributes(*attrs)
attributes(*attrs)