User Field not working in a plugin outlet

I’m trying to add this user field: user-fields/5 in this outlet: above-user-summary-stats. But it does not load, here is the hbs I’m trying to use:

{{!-- Display and edit a custom user field (e.g., "profile note") for user_field_5 --}}
{{#if this.fieldValue}}
  <div class="profile-note-display">
    <strong>Profile Note:</strong> {{this.fieldValue}}
  </div>
{{else}}
  {{#if this.canEdit}}
    <div class="profile-note-display empty">
      <em>No profile note set</em>
    </div>
  {{/if}}
{{/if}}

{{#if this.canEdit}}
  {{#unless this.editing}}
    <button class="btn btn-primary btn-small" {{on "click" this.startEdit}}>
      {{#if this.fieldValue}}Edit{{else}}Add{{/if}} Profile Note
    </button>
  {{/unless}}
{{/if}}

{{#if this.editing}}
  <form {{on "submit" this.save}}>
    <textarea
      rows="4"
      style="width:100%;"
      value={{this.editValue}}
      {{on "input" this.updateEdit}}
      autofocus
    ></textarea>
    <br>
    <button type="submit" class="btn btn-primary btn-small">Save</button>
    <button type="button" class="btn btn-conditional btn-small" {{on "click" this.cancelEdit}}>Cancel</button>
  </form>
{{/if}}

What can be the possible issue?

1 Like

I don’t think we have enough information to help based on this template alone. How is this.fieldValue defined?

If you enter user_field_5 in the site setting Public user custom fields… you should be able to access it from this plugin outlet

Either in your template like: {{@user.custom_fields.user_field_5}}

or in your JS as: this.args.user?.custom_fields?.user_field_5

Alternatively, if you don’t want the field to be public you can skip the site setting change and use this.args.user?.user_fields?.[5]

1 Like