+ Reply to Thread
Results 1 to 5 of 5

Thread: wiki.Getuser error

  1. #1
    Join Date
    Feb 2009
    Posts
    33

    Default wiki.Getuser error

    Hi there,

    I´m trying to use the wiki function GetUser to show at least some welcoming message for my users. Unfortunately the function doesn´t work. It doesn´t work both at my local wiki installation and the wiki at wiki.developer.mindtouch.com (http://wiki.developer.mindtouch.com/.../Wiki.GetUser).

    All I get is this message:

    Code:
    { anonymous : true, api : "http://wiki.developer.mindtouch.com/@api/deki/users/754", emailhash : "d41d8cd98f00b204e9800998ecf8427e", feed : "http://wiki.developer.mindtouch.com/@api/deki/users/754/feed", gravatar : "http://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e.png", homepage : "local://1a51afad1a87466e9e59da41cb12195a/deki/$page#%5b+5811+%5d", id : 754, name : "Anonymous", uri : "http://wiki.developer.mindtouch.com/User:Anonymous" }
    At my local installation Anonymous is replaced by my admin login of course. Is this an API problem or a local problem on my side (using both IE and FF).

    Thank you,

    Joerg

  2. #2
    Join Date
    Feb 2008
    Location
    London upon Thames
    Posts
    2,792

    Default

    It's working correctly. The results are a map of the attributes about the current user.

    Did you want only one of the pieces of information, like the 'name' perhaps?

    Code:
    {{ wiki.getuser("crb")["name"] }}
    If my post helped you, please click the icon below this post to my reputation. Thanks!

  3. #3
    Join Date
    Feb 2009
    Posts
    33

    Default

    Yes, just the name itself. The code at the developer-wiki says:
    Code:
    {{wiki.getuser(user.name)}}
    So I thought using this exact code will extract the username of the currently logged in user and print it to screen.

    I wanted to greet every user with something like "Welcome, username.". Your code example uses a specific username (crb) though. I´m a bit clueless.

    Thanks,

    J-

  4. #4
    Join Date
    Feb 2009
    Posts
    33

    Default

    Nevermind, I just figured it out with your example.
    Code:
    {{wiki.getuser(user.name)["name"]}}
    gives me exactly what I needed. Thanks again. This is great once you get the logic behind it. Now I even understand what you meant with the maps of attributes. I misinterpreted it as an error message.

    J-

  5. #5
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    If the name you're looking up is simple (i.e. alphanumeric), you can also use the dot-notation like this:
    Code:
    {{ wiki.getuser(user.name).name }}
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts