Embed variables in footer

Hi, I’d like to embed the SSO external_id in some custom Javascript I’m pasting into my theme footer (using the ‘Custom HTML/CSS’ button)… is there a way to access the external_id from that template? i.e. something sorta like:

<script>
   var id = {{ sso.external_id }};
</script>

If I can’t embed external_id, I would love to be able to embed the username and email.

Hi,
you could map sso field to custom user field and use it like this

const user = api.getCurrentUser()
console.log(user.custom_fields.external_id)

How to map sso field to custom user field, check here: Official Single-Sign-On for Discourse (sso)

You need to make that custom field public in the settings in order to access it in the theme.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.