Return the current user's custom fields

This commit is contained in:
Robin Ward 2014-06-05 16:16:30 -04:00
parent f085770ed4
commit 651def63e5
2 changed files with 9 additions and 1 deletions

View File

@ -455,6 +455,7 @@ Discourse.Composer = Discourse.Model.extend({
username: currentUser.get('username'),
user_id: currentUser.get('id'),
uploaded_avatar_id: currentUser.get('uploaded_avatar_id'),
user_custom_fields: currentUser.get('custom_fields'),
archetype: this.get('archetypeId'),
post_type: Discourse.Site.currentProp('post_types.regular'),
target_usernames: this.get('targetUsernames'),

View File

@ -20,7 +20,8 @@ class CurrentUserSerializer < BasicUserSerializer
:can_delete_account,
:should_be_redirected_to_top,
:redirected_to_top_reason,
:disable_jump_reply
:disable_jump_reply,
:custom_fields
def include_site_flagged_posts_count?
object.staff?
@ -70,4 +71,10 @@ class CurrentUserSerializer < BasicUserSerializer
object.redirected_to_top_reason.present?
end
def custom_fields
return {} unless SiteSetting.public_user_custom_fields.present?
fields = User.custom_fields_for_ids([object.id], SiteSetting.public_user_custom_fields.split('|'))
return fields.present? ? fields[object.id] : {}
end
end