• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

How add username to panel header?

Scheduled Pinned Locked Moved Solved Technical Support
8 Posts 4 Posters 339 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NodeBB socks.
    wrote on last edited by
    #1

    Hello 👋

    Please help me, how to show username in panel header?

    I try

    Welcome, {{username}}
    

    it’s not work.

    Example, when user log in to forum, he is view welcome banner (panel) with text “Welcome to forum @Username”

    dunlixD 1 Reply Last reply
    0
  • dunlixD Offline
    dunlixD Offline
    dunlix GNU/Linux Gamers
    replied to NodeBB socks. on last edited by
    #2

    @maiseu I think @phenomlab did something similar to this

    phenomlabP 1 Reply Last reply
    0
  • phenomlabP Offline
    phenomlabP Offline
    phenomlab
    replied to dunlix on last edited by
    #3

    @dunlix I did, yes, but it's usage case is somewhat restricted without creating a plugin - see https://community.nodebb.org/topic/16052/widget-code-works-on-one-nodebb-instance-but-not-another/2?_=1635504604510

    N 1 Reply Last reply
    0
  • N Offline
    N Offline
    NodeBB socks.
    replied to phenomlab on last edited by
    #4

    @phenomlab I need add to panel this code, yes?

    <div class="mypanel123">Welcome to forum, <a href="/me"><span class="username">{user.username}</span></a></div>
    
    phenomlabP 1 Reply Last reply
    0
  • phenomlabP Offline
    phenomlabP Offline
    phenomlab
    replied to NodeBB socks. on last edited by
    #5

    @maiseu Yes, but it probably won't work because of the issues I raised in the post I referenced.

    1 Reply Last reply
    1
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #6

    This should work if you don't want to write a plugin to provide the user object.

    <div class="mypanel123">Welcome to forum, <a href="/me"><span class="username"></span></a></div>
    <script>
    function updateUsername() {
        $('.mypanel123 .username').text(app.user.username);
    }
    if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', updateUsername);
    } else {
            updateUsername();
    }
    </script>
    
    phenomlabP 1 Reply Last reply
    2
  • phenomlabP Offline
    phenomlabP Offline
    phenomlab
    replied to <baris> on last edited by
    #7

    @baris Confirmed working ! Thanks very much 🙂

    1 Reply Last reply
    0
  • N NodeBB socks. deleted this topic on
  • barisB baris restored this topic on
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote last edited by
    #8

    On latest version of NodeBB you no longer need the js code, since the logged in user is provided in the loggedInUser object. So you can use the below html widget.

    <div class="mypanel123">Welcome to forum, <a href="/me">{loggedInUser.username}</a></div>
    
    1 Reply Last reply
    2
  • barisB baris has marked this topic as solved

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development