Getting a username on any wiki page of Trac (Trac 0.11)

When I create a report, I can filter the results based on the username with the name using the $ USER magic variable. Is there any equivalent way to get the logged in username on any Trac wiki?

For example: registered user: [[User]].

+5
source share
1 answer

It looks like you need a plugin for this. Nothing complicated; just drop this:

from trac.wiki.macros import WikiMacroBase

class UserMacro(WikiMacroBase):
    def expand_macro(self, formatter, name, args):
        return formatter.req.authname;

In the file type <trac_env>/plugins/username.pyand add [[User]]to the wiki page. For unregistered users, it will show anonymous.

+9
source

All Articles