Can you create a personalized greeting on a Confluence page?

Cathy Li April 19, 2021

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.

1 answer

1 accepted

1 vote
Answer accepted
Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 20, 2021

Hi @Cathy Li 

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

Confluence has a macro on which we can inject HTML, which includes JavaScript code and CSS. See the HTML Macro product documentation 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

 

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

user-macro-002.png

 

User Macro

You may also choose to take advantage of the user macros feature in Confluence.
With this feature you can create your own macros and use it on any page, similar to the default macros shipped with Confluence or the Marketplace Apps.

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

 

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

 

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

user-macro-005.png

 

 

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

Kind regards,
Thiago Masutti

Cathy Li April 20, 2021

Hi @thiagomasutti 

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.

Cathy Li April 22, 2021

Hi @thiagomasutti 

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.

Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 23, 2021

Hi @Cathy Li 

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

Cathy Li April 23, 2021

Hi @Thiago Masutti  

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.

Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 23, 2021

Hi @Cathy Li 

That's great!!!

I'm glad to know it helped.

Have a great weekend too.

Regards

Carmela Di Francesco
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 18, 2024

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.

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events