You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Craftercms - Social:能否指定"create comment" API获取的用户属性?

Controlling User Attributes in CrafterCMS "Create Comment" API Response

Great question! Let me walk you through how to tailor the user.attributes field in the "create comment" API response to your needs, based on CrafterCMS v3.0's Social API documentation:

  • Use the fields parameter to pick specific attributes
    When sending your POST request to the comment creation endpoint, add the fields query parameter to explicitly list which user attributes you want included.

    For example, if you only need the displayName and profilePictureUrl attributes under user.attributes, your request URL would look something like this:

    /api/3/social/ugc/comments/create?fields=user.attributes.displayName,user.attributes.profilePictureUrl
    

    This tells the API to only return those two attributes in the response's user object.

  • Use excludeFields to omit unwanted attributes
    If you want most user attributes but need to leave out a few specific ones, use the excludeFields parameter instead. Say you don't want the privateNotes attribute returned—your request would include:

    /api/3/social/ugc/comments/create?excludeFields=user.attributes.privateNotes
    
  • Default behavior to keep in mind

    If you don't specify either fields or excludeFields, the API will return all available user attributes stored in the system for that user by default.

Just a quick heads-up: You can only request attributes that are actually saved for the user in your CrafterCMS instance—you won't be able to pull attributes that weren't stored in the first place.

内容的提问来源于stack exchange,提问作者Isai Ulate Sancho

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:44:24