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



  • 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?


  • Community Rep

    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>
    

Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.