How to generate Dynamic URL link base on login user information

Hi All,

I have to generatate a dynamic url link on my wiki page. it will like :

use login user infomation to get the parameter of the url from another database and generate it.

for example :

login user is smith , the url will be : && pagenumber=33

login user is Don the url will be : && pagenumber=36

Any suggestion is appreciatged


4 answers

1 accepted

1 vote
Davin Studer Community Champion Feb 27, 2014

Here is some rough code. You would need to wrap it in a html macro.

<script type="text/javascript>
    var user = AJS.Meta.get('remote-user');

        type: 'GET', //or POST
        url: 'Your URL', //this should pass back the parameter based on the user submitted to it
        processData: true,
        data: {
            u: user
        dataType: 'json' //xml, json, script, or html
        success:  function(data) {
            var pagenumber = //Your logic to get the parameter here;

            AJS.$('#container to hold the link').append('<a href="' + user + '&pagenumber=' + pagenumber  + '">Link Text</a>');
        error:  function(x, y, z) {
            //Error handling code here.

0 vote
Davin Studer Community Champion Feb 27, 2014

You have a couple options. One would be to write your own plugin. If you don't want to go that far then you would to enable the html macro so that you can embed some Javascript. You can get the user using this Javascript method.


Confluence has jQuery installed, so you could use AJS.$.Ajax(); to get the parameters from an outside web service. Then you would just assemble the link with those parts.


Thanks for the response, can you provide any sample code about this.

Thanks again

Thank you very much!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

372 views 20 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you