Can you create a personalized greeting on a Confluence page?
Asked by Cathy Li:

Hello,

I'm editing a home page for this space and thought it might be nice to have a greeting for anyone who's visiting.

Is there a way to create a personalized greeting message at the beginning of the page? For example: Hello \<person who's visiting\> or something to that effect?

I looked around on Google a bit but haven't found a specific use case.

Does anyone have any suggestions?

Thanks so much.


Answers:
author: Thiago Masutti
body: Hi [@Cathy Li](/t5/user/viewprofilepage/user-id/4356116)

Welcome to the Atlassian Community.

Although Confluence doesn't have something out-of-the-box for that purpose, it is flexible enough for us to create it.  
I know two possible ways we could achieve what you need. For both, you will need help from your Confluence administrator -- if it's not you :smile: .

#### Confluence HTML macro {#toc-hId--566470673}

Confluence has a macro on which we can inject HTML, which includes JavaScript code and CSS. See [the HTML Macro product documentation](https://confluence.atlassian.com/doc/html-macro-38273085.html) for more details about it.

In this case, you will need a Confluence administrator to enable this Macro, since it is disabled with a default installation.  
There might be some security constraints on enabling it on your company. If so, check the next solution.

If the macro is already enabled, you can use a JavaScript code to get the full name of the authenticated user -- the user reading your page.  
The code below is a simple one to get you started in case you choose this option.

```
Hi<script type='text/javascript'>document.write(AJS.params.currentUserFullname);</script>

```

In the editor, this code with the HTML macro will look like the below

![user-macro-001.png](https://community.atlassian.com/t5/image/serverpage/image-id/139492i437DF3BDF74F49C6/image-dimensions/384x231?v=v2 "user-macro-001.png")

Then, a user reading the page would see something like this

![user-macro-002.png](https://community.atlassian.com/t5/image/serverpage/image-id/139493i8009E611C009DDEE/image-dimensions/391x295?v=v2 "user-macro-002.png")

#### User Macro {#toc-hId-1921042160}

You may also choose to take advantage of the [user macros feature](https://confluence.atlassian.com/doc/writing-user-macros-4485.html) in Confluence.  
With this feature you can create your own macros and use it on any page, similar to the [default macros](https://confluence.atlassian.com/doc/macros-139387.html) shipped with Confluence or the [Marketplace Apps](https://marketplace.atlassian.com/search?hosting=dataCenter&product=confluence).

This might be a preferred approach since any user in your instance may take advantage of the macro once it is configured.  
You will need help from a Confluence administrator to publish this macro.

To get you started, the user macro code will be like this:

```
## Macro title: current-user
## Macro has a body: N
## Body processing: N
## Output: remote user name
##
## Developed by: <Name>
## Date created: <dd/mm/yyyy>
## Installed by: <Name>
## @noparams

$action.authenticatedUser.fullName
```

Below is a screenshot of the full configuration for the user macro -- you may change it depending on your environment.

![user-macro-003.png](https://community.atlassian.com/t5/image/serverpage/image-id/139494iDAB85AA5570088F0/image-dimensions/437x553?v=v2 "user-macro-003.png")

After the macro is published by the Confluence administrator, you can use it in your page by typing its name in the editor.

![user-macro-004.png](https://community.atlassian.com/t5/image/serverpage/image-id/139495i1DA534398A796118/image-dimensions/460x300?v=v2 "user-macro-004.png")

While in the editor your page would look like below, users reading it would see their name.

![user-macro-005.png](https://community.atlassian.com/t5/image/serverpage/image-id/139496i3BD886C4D11987B8/image-dimensions/373x243?v=v2 "user-macro-005.png")

I hope one of these approaches helps you with what you need.

Kind regards,  
Thiago Masutti

comments: author: Cathy Li
body: Hi [@thiagomasutti](/t5/user/viewprofilepage/user-id/1390688)

Thanks so much for the detailed answer :) I appreciate the thoroughness.

I'm not an admin but I guess the HTML macro has been enabled.

I tried the first option and worked like a charm. Thanks again.


author: Cathy Li
body: Hi [@thiagomasutti](/t5/user/viewprofilepage/user-id/1390688)

Sorry to back track one step -- I know that Confluence doesn't distinguish given name from surname, but is there a work-around to display only the current user's given names?

Thank you so much for your help.


author: Thiago Masutti
body: Hi [@Cathy Li](/t5/user/viewprofilepage/user-id/4356116)

Confluence may not have that information, but we may try something with Java Script.

We can take the full name as a string, split it based on spaces and show only the first part of the substring.

In my case it would be Thiago; Cathy in yours.  
It's not bullet proof, but may work most of the times.

The new code should be something like this:

```
Hi<script type='text/javascript'>document.write(AJS.params.currentUserFullname.split(" ")[0]);</script>
```

Let me know if that helps.

Kind regards,  
Thiago Masutti


author: Cathy Li
body: Hi [@Thiago Masutti](/t5/user/viewprofilepage/user-id/1209618)

You are a genius! Thanks so much :)

On our Confluence, the names are organized as Last Name, First Name, so I changed the 0 to 1 from your code and it worked!

Thank you so so much and thank you for helping again after the initial issue is resolved :)

Have a great weekend.


author: Thiago Masutti
body: Hi [@Cathy Li](/t5/user/viewprofilepage/user-id/4356116)

That's great!!!

I'm glad to know it helped.

Have a great weekend too.

Regards


author: Carmela Di Francesco
body: hi,

I am using currentUserFullname however this displays the name as lastname, firstname. How can i show just the first name or first and last name?

```
Hi<script type='text/javascript'>document.write(AJS.params.currentUserFullname.split(" ")[0]);</script>
```

Thanks.


Tags: confluence-server

server