Passing user's logged in data to embedded Paperform

Similar to @Ezra 's code for passing data to an embedded Typeform form, I’ve changed it slightly so it works for an embedded Paperform form.

<script>
if(window['logged_in_user'] && window['logged_in_user']['softr_user_email']) {
nameData = 'name=' + window['logged_in_user']['Name']; 
emailData = 'email=' + window['logged_in_user']['Email'];
useridData = 'userid=' + window['logged_in_user']['userID'];
hiddenFields = nameData + `&` + emailData + `&` + useridData;

document.writeln(`<div prefill="`+ hiddenFields +`" prefill-inherit data-paperform-id="FORM_ID_GOES_HERE"></div>
`); 
}
</script>

<script>(function() {var script = document.createElement('script'); script.src = "https://paperform.co/__embed.min.js"; document.body.appendChild(script); })()</script>
3 Likes

Thanks for that! Very useful!

Thank you very much @datom for sharing it with us!