This code snippet adds the authenticated user's email address to a hidden form field. The address will be part of the data captured by the form and can be used when you further handle the form submission.

Prerequisite 

The script relies on the hidden input having an id attribute. Ensuring that the ID attributes are unique is essential; some site builders help make this happen. For instance, when adding a value for id in the Carrd form builder, the value is prepended by a unique form id.

Screenshot of the id in the html created by Carrd

The Snippet

Add the provided custom code snippet (found between <!-- ✨ Custom Code Snippet Start ✨ --> and <!-- ✨ Custom Code Snippet End ✨ -->) to the head of your site below the Outseta script, which should already be in your site's head tag.

When the nocode module has been initialized, let's get the payload for the authenticated user and set the hidden input field to that value.

<!-- Outseta Script Options -->
<script>
var o_options = {
domain: '[your-domain].outseta.com',
};
</script>

<!-- Outseta Script (doing all the magic) -->
<script src="https://cdn.outseta.com/outseta.min.js" data-options="o_options"></script>


<!-- ✨ Custom Code Snippet Start ✨ -->
<script>
Outseta.on("nocode.initialized", async () => {
const payload = Outseta.getJwtPayload();
if (payload) {
// ❕ Change "super-unique-id" to the id of your input field
document.getElementById("super-unique-id").value = payload.email;
}
});
</script>
<!-- ✨ Custom Code Snippet End ✨ -->

Full demo on Code Sandbox