Hi everyone,
I am currently trying to show user logged in data - such as their name - in text blocks.
I have followed Artur’s guide (How to show logged in user's name in the website) and it works perfectly for custom code blocks (thank you btw! )
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!