Forum Discussion

teknetik's avatar
12 years ago
Solved

Find the userid of an author

I am writing a small "badges" addin for Lithium. I have found the place where I can add a custom component to an authored post.

 

What I am looking for is freemarker or a rest call that will return me the userid of that specific post?

 

Any ideas anyone? :)

  • So I thought I had the full answer but it seems not. Here is my updated code for other newbies:

     

    <#assign author= env.context.message.author />
    
    <h1>${author.login}</h1>

     

    That will print out JUST the author.

     

    <#assign author= env.context.message.author />
    
    <h1>${author.id}</h1>

      Just the ID

     

    Hope this post helps someone else out oneday....

     

     

     

3 Replies

  • teknetik's avatar
    teknetik
    Ace
    12 years ago

    So I thought I had the full answer but it seems not. Here is my updated code for other newbies:

     

    <#assign author= env.context.message.author />
    
    <h1>${author.login}</h1>

     

    That will print out JUST the author.

     

    <#assign author= env.context.message.author />
    
    <h1>${author.id}</h1>

      Just the ID

     

    Hope this post helps someone else out oneday....

     

     

     

  • iftomkins's avatar
    iftomkins
    Maven
    12 years ago

    Thanks so much! This is very useful, and not super obvious in the documentation, likely because the object is called "env" instead of "post" or "message" or something. It is also mentioned in this post: http://community.lithium.com/t5/Developers-discussion/Accessing-Author-information-for-custom-component/m-p/136652#M5299.

     

    Please excuse the multiple code updates on the referenced post. The final code should work for a custom author component, though--really.