Return the current user's custom fields
This commit is contained in:
parent
f085770ed4
commit
651def63e5
2 changed files with 9 additions and 1 deletions
app
|
@ -455,6 +455,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
username: currentUser.get('username'),
|
username: currentUser.get('username'),
|
||||||
user_id: currentUser.get('id'),
|
user_id: currentUser.get('id'),
|
||||||
uploaded_avatar_id: currentUser.get('uploaded_avatar_id'),
|
uploaded_avatar_id: currentUser.get('uploaded_avatar_id'),
|
||||||
|
user_custom_fields: currentUser.get('custom_fields'),
|
||||||
archetype: this.get('archetypeId'),
|
archetype: this.get('archetypeId'),
|
||||||
post_type: Discourse.Site.currentProp('post_types.regular'),
|
post_type: Discourse.Site.currentProp('post_types.regular'),
|
||||||
target_usernames: this.get('targetUsernames'),
|
target_usernames: this.get('targetUsernames'),
|
||||||
|
|
|
@ -20,7 +20,8 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||||
:can_delete_account,
|
:can_delete_account,
|
||||||
:should_be_redirected_to_top,
|
:should_be_redirected_to_top,
|
||||||
:redirected_to_top_reason,
|
:redirected_to_top_reason,
|
||||||
:disable_jump_reply
|
:disable_jump_reply,
|
||||||
|
:custom_fields
|
||||||
|
|
||||||
def include_site_flagged_posts_count?
|
def include_site_flagged_posts_count?
|
||||||
object.staff?
|
object.staff?
|
||||||
|
@ -70,4 +71,10 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||||
object.redirected_to_top_reason.present?
|
object.redirected_to_top_reason.present?
|
||||||
end
|
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
|
end
|
||||||
|
|
Reference in a new issue