Gadget Displaying Member Name
We would love to see a gadget that displays the member's name. This gadget could be similar to the Login Button Gadget, but showing instead the member's full name only.
This would allow to greatly personalize the member's experience on his/hers content pages, such as greeting them on their homepage. For example: WELCOME ON YOUR HOMEPAGE [(FULL_NAME)].
-
Robin Sapiro commented
So tried this piece of code as shown and it works just fine.
However some questions:
1. Can it be used in any other way to display any other fields from the logged in user? Example: First name only, email address, phone number and any other fields that have been defined for that membership level by the system administrator. If so what would the revised code look like?
2. Can it be used to display any fields from a specified contact (member) that is hard coded (not derived from the current logged in member)?
-
Hello there!
For this purpose you can use following snippet in 2 ways:
<script type="text/javascript">(function() { var container = document.querySelector('.loggedName') || document.querySelector('.loginBoxProfileLink'); if (container) { document.write(container.innerText.replace(/[\n\r]/g, '') || 'Guest'); } else { document.write('<div class="userClass_MemberName"></div>'); WA.PageParsed(function() { var container = document.querySelector('.loggedName') || document.querySelector('.loginBoxProfileLink'), out = document.querySelector('.userClass_MemberName'); if (out) { out.innerHTML = (container ? container.innerText.replace(/[\n\r]/g, '') || 'Guest' : 'Guest'); }}, window);}})();</script>1) Paste it into Custom HTML gadget.
2) Paste it during editing Content gadget by inserting snippet (Button "<S>")It is save to try ;)