Content by User Macro
Asked by Ralf Loessner:

Hi Experts,

who can tell me, if the parameter "**username** " of the macro "**content by user** " can be set dynamic?  
I'll design a page with the user macro "content by user" an it should be displayed the content of the **current user, who is loggin in** and visit this page.  

Is there any solution for this demand?  

<br />

<br />

Thank you so much  

Ralf


Answers:
author: Stephen Deutsch
body: Hi Ralf,

Perhaps the scripting plugin is a security issue, but how about a user macro? If you are using confluence 5.2 or higher, this will work:

```
## @noparams&lt;ac:structured-macro ac:name="content-by-user"&gt;  &lt;ac:parameter ac:name=""&gt;    &lt;ri:user ri:userkey="${action.authenticatedUser.key}"/&gt;  &lt;/ac:parameter&gt;&lt;/ac:structured-macro&gt;
```

You could call it "Content by Current User" or something like that.

Best regards,

Stephen

comments: author: Anne EQS
body: Hi,

added the user macro but unfortunately it returns the error message 'Error rendering macro 'content-created-by-current-user' : null' (Confluence 5.8.5)

Did anyone face the same problem - and found a way to solve it?

BR, Anne


author: Milo Test
body: And nothing is displayed in 5.8.9.


author: Stephen Deutsch
body: I'm sorry, but I simply don't have enough time to fire up a test instance right now. Maybe I'll get a chance later in the week to try and fix it.


author: Davin Studer
body: I created it in 5.5.6 and 5.8.6 and it works fine in both.


author: Anne EQS
body: Finally works! You have to set the Macro Body Processing to 'Escaped' - NOT to 'No Macro Body'


author: Davin Studer
body: Macro Body Processing should really be set to "No macro body" as you are not embedding anything inside the user macro.


author: Timothy
body: I know you can do it if you use the Scripting Pluigin to get the current user and then output the **content by user macro** as wiki.


author: Sabu Nair
body: Hi ,

I used this user-macro and got error for LDAP users. Error "rendering macro 'content-by-user' : null" . We are using confluence 5.8.6 Server and Crowd integrated with LDAP. (For Non LDAP user this user-macro worked)

## @noparams  
\<ac:structured-macro ac:name="content-by-user"\>  
\<ac:parameter ac:name=""\>  
\<ri:user ri:userkey="${action.authenticatedUser.key}"/\>  
\</ac:parameter\>  
\</ac:structured-macro\>

Is userkey for systems using LDAP/Crowd different?. Any suggestion to solve this?.

Thx


author: Anne EQS
body: Thanks for your help, finally got it to work. :smile: Now 'll start restricting it by type (page, blog post, comment) - any hints for that?


author: Doug Swartz
body: If you have the [Run Self-Service Reports for Confluence](https://bobswift.atlassian.net/wiki/display/RUN?src=breadcrumbs-homepage) plugin, embed the Content by User macro in a Run without a user form macro. Specify $current_user_id as the user.

This has been been tested in 5.4.4 and 5.8.6.

comments: author: Davin Studer
body: Sure that works too, but the above example is free and less involved as you need only one macro on that page that doesn't need any params.


author: Doug Swartz
body: You are correct. The challenge is that user macros in Confluence aren't really user macros. They are "defined by administrator" macros. The Run Self Service Reports alternative is usable by non-administrators if the appropriate plugin is already in place. It's also easily generalizable to allow selecting from a list of users.


author: Sabu Nair
body: Hi ,I used this user-macro and got error for LDAP users. Error "rendering macro 'content-by-user' : null" . We are using confluence 5.8.6 Server and Crowd integrated with LDAP. (For Non LDAP user this user-macro worked)## @noparams \<ac:structured-macro ac:name="content-by-user"\> \<ac:parameter ac:name=""\> \<ri:user ri:userkey="${action.authenticatedUser.key}"/\> \</ac:parameter\> \</ac:structured-macro\>Is userkey for systems using LDAP/Crowd different?. Any suggestion to solve this?. Thx


author: Miguel Botto
body: Hi Sabu, I have the same issue, did you finally find a solution?


author: Ralf Loessner
body: Thank you so much, but we can't use this. it is question of security and the policy says NO.

Best regards,  
Ralf

comments: author: Davin Studer
body: What is a question of security? The answer by Stephen Deutsch doesn't open any security holes. You are not adding in any foreign code or anything like that. It is using only built-in functionality.


author: Stephen Deutsch
body: If I remember correctly, I think he was referring to Timothy Chin's answer :)


author: Davin Studer
body: Ah ... ok! I was looking at the dates of the posts and it looked to me like he was referring to your ... kinda confused me.