How would you change this to pull in another field from the Users Airtable table?
Like the above comment, I would also like to know how we can pull in other fields from Airtable. Or is it limited to just the name?
Hi everyone,
I have followed Artur’s guide and it works perfectly for custom code blocks but not for other blocks though, such as “hero with CTA”. It usually works once and then it doesn’t when you refresh the page. I’ve tried to find a solution, without any success so far…
Here is the code I used:
<script>
document.addEventListener("DOMContentLoaded", function () {
if(window.logged_in_user) {
const name = window.logged_in_user.softr_user_full_name;
$("span:contains('{LOGGED_IN_USER:NAME}')").removeClass('student-name');
$("span:contains('{LOGGED_IN_USER:NAME}')").html(name);
}
});
</script>
Here is a screenshot of the two different blocks, you can see that it’s working for the first one (custom code) but not for the second one.
Does anyone know how to solve this issue?
Thanks for your time!
@Theo use the code below:
<script>
window.addEventListener('block-loaded-blockname1', () => {
console.log('Block loaded');
if(window.logged_in_user) {
const name = window.logged_in_user.softr_user_full_name;
$("span:contains('{LOGGED_IN_USER:NAME}')").removeClass('student-name');
$("span:contains('{LOGGED_IN_USER:NAME}')").html(name);
}
});
</script>
blockname1
- needs to be your block’s name as shown in the studio settings see the pic below.
1 Like