How add space parameter to Content by User macro
Asked by boardtc:

The *Content by User* macro says you can filter by Space in the [documentation](https://confluence.atlassian.com/confcloud/content-by-user-macro-724765179.html):

{content-by-user:author=jsmith\|spaceKey=all\|max=25}

From [Confluence Wiki Markup](https://confluence.atlassian.com/doc/confluence-wiki-markup-251003035.html) Using Insert \| Markup and adding above gives:

![contentmacro.png](https://community.atlassian.com/t5/image/serverpage/image-id/33412i8F8907C0DC12158F/image-size/large?v=v2&px=999 "contentmacro.png")However, I can include the macro using the WYSIWYG and it shows fine specifying the author *but*for all the spaces and I just want to restrict to the current space.

Trying with Markup of:

{content-by-user:author=jsmith}

Gives the same errror of "no pages at the moment" also. What am I missing, why is the markup not working?


Answers:
author: Bill Bailey
body: The associated tag says server, but you doc link you sent was for cloud. The server version does not have the ability to screen for space. And I think that the doc you are looking at is out of date regarding the wiki markup (it is slated for deprecation), for example, that sample does not appear on the server docs.

comments: author: boardtc
body: Good spot. The [corresponding documentation](https://confluence.atlassian.com/conf66/content-by-user-macro-943962058.html) for our server version confirms that the server version does not support space in the Markup. Atlassian have a smelly code base that they have to code twice to add functionality in the cloud \& server versions.

Thats said the markup for the author does not work either, which is a bug. But that does not help me.


author: Bill Bailey
body: Check the user name (differs from the display name). Also try other user names (for example if there was a change in user directories, could cause none to appear).

I tried on my Instance 5.10.x, inserting the markup into the wiki markup macro, and it worked as expected.

But generally, this is a situation where you will need to create a user macro to do what you want.


author: boardtc
body: I didn't know I could create a custom macro to do the likes of this, can you point me to any resource, please?


author: Bill Bailey
body: Sure, the first part is to start with the user docs:

<https://confluence.atlassian.com/conf610/user-macro-template-syntax-952622979.html>

But you will have to do research from there, looking at complex examples of macros plus the Confluence API docs to find what available objects and methods are available.

Here is an example of a complex macro with good tips and hints:

<https://github.com/unidwell/confluence-include-child-pages-macro>

There are also some articles here, they can give you tips and hints:

<https://community.atlassian.com/t5/tag/user-macro/tg-p/interaction-style/blog>

So lots of googling to get started, some basic knowledge of VTL, and familiarity with the concept of Java objects and methods. I knew none of this when I started FYI.

User macros are very powerful and allow you to fill holes in Confluences.

Good luck!


author: boardtc
body: Thanks!


Tags: confluence-server

macro

server