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.
Hi everyone now this feature is super simplified in Softr. You just need to place the {LOGGED_IN_USER:NAME} placeholder in the corresponding field and it will display the user’s name in preview. Enjoy