We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1783
    • 23 Posts
    Hi, I’m using WebloginPe for user profiles, I’ve got problem with displaying username in sidebar in welcome message. Im not using [!Webloginpe !] call in sidebar as I have custom links there only visible when user is logged in. To display username I found only one working solution (it is however working within first two or three pages and then dissapears, probably when I’m leaving the weblogin pages (like ’edit profile’ for example)

    To display username I created snippet:
    $user = $modx->getLoginUserName();
    if ($user) {
    return $user;
    } else {
    which I’m calling in sidebar: [!Username!].

    I tried different combinations with cached and uncached, and it doesn’t help, however I have all pages ’uncached’ as this was the only way to have custom menu in sidebar visible to logged in users only.

    Can anyone help please, how to have username displayed for all the time, until logged out?
      • 3749
      • 24,544 Posts
      You could use the Personalize snippet, which shows one chunk to logged in users and another to everyone else. I think it sets a placeholder for the user’s name, but I’m not sure.

      With your original code, try setting a placeholder in your snippet:


      And displaying it with [+UserName+] in the sidebar. Note that you’ll still have to have your snippet tag on the page (put it near the top of the <body> section of the template, rather than in the page content), but have the snippet return an empty string:

      (return "");
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 1783
        • 23 Posts
        thank you for your replies,
        I couldn’t make the above suggestions work, however I’ve got more details to my problem: I’ve noticed that when I’m using my snippet, the username is displayed properly on any pages until I click on UPDATE PROFILE submit button on profile edition page.

        Is there any way to fix that?