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.
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 .
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
Then, a user reading the page would see something like this
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.
After the macro is published by the Confluence administrator, you can use it in your page by typing its name in the editor.
While in the editor your page would look like below, users reading it would see their name.
I hope one of these approaches helps you with what you need.
Kind regards,
Thiago Masutti
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.