Is it possible to access the user ID via a widget?

NodeBB Plugins
  • I want to access the user ID of the the logged in user and the user I'm visiting. Is this possible with a widget or do I have to write a plugin?

  • The logged in user should be app.user.uid, if you are visiting a user, the id should be ajaxify.data.theirid

    Here's a small script for you.

    <span id="myid" style="display:none;">My uid: </span>
    <span id="theirid" style="display:none;">Their uid: </span>
    <script>
    if (app.user.uid) {
      $('#myid').append(app.user.uid)
      $('#myid').show()
    }
    if (ajaxify.data.theirid) {
      $('#theirid').append(ajaxify.data.theirid)
      $('#theirid').show()
    }
    </script>
    


Suggested Topics