XF 2.3 Getting Custom User Field Text

QuackieMackie

New member
I created a custom user field, and now I'm trying to use that text value, for a template. How can I get that text value?

In my template I did this so I could use the custom user banner css without copying it to multiple places:
PHP:
<xf:if is="$user.Profile.custom_fields.pronouns">
    <div class="staff-pronouns">
        <span class="userBanner userBanner--syl_pro_{$user.Profile.custom_fields.pronouns}">{$user.Profile.custom_fields.pronouns}</span>
    </div>
</xf:if>

But this is only showing the values with the _ rather than the text value with the /

1751805533043.webp
 
Last edited:
Solution
I figured it out, you can use phrase_dynamic to use variables.
PHP:
<xf:if is="$user.Profile.custom_fields.pronouns">
    <div class="staff-pronouns">
        <span class="userBanner userBanner--syl_pro_{$user.Profile.custom_fields.pronouns}">
            {{ phrase_dynamic('user_field_choice.pronouns_' . $user.Profile.custom_fields.pronouns) }}
        </span>
    </div>
</xf:if>
I figured it out, you can use phrase_dynamic to use variables.
PHP:
<xf:if is="$user.Profile.custom_fields.pronouns">
    <div class="staff-pronouns">
        <span class="userBanner userBanner--syl_pro_{$user.Profile.custom_fields.pronouns}">
            {{ phrase_dynamic('user_field_choice.pronouns_' . $user.Profile.custom_fields.pronouns) }}
        </span>
    </div>
</xf:if>
 
Solution
Back
Top Bottom