I have added a menu item to the Personal Actions menu by creating a CustomAction like so:

    Title="My Link"
    Description="This is my custom link."
    <UrlAction Url="http://www.example.com/" />

However, I want a dynamic URL. There is a URL parameter that changes based on the current user. How can I make that happen? (By the way, this is an external URL, and not part of the SharePoint site.)

1 Answer 1


Create a custom ASP.NET page e.g. ApplPage1.aspx and then let user navigate to this page like this,

<UrlAction Url="_layouts/TestProject/ApplPage1.aspx">

Now in your Page.Load event of ApplPage1.aspx, check user's identity using,

SPWeb theSite = SPControl.GetContextWeb(Context);
SPUser theUser = theSite.CurrentUser;
string strUserName = theUser.LoginName;

Make sure you dispose SharePoint objects as otherwise it will be a massive memory leak. Once you got UserName, you can use If/else or switch statement to navigate user to website you want to navigate him.

Hope it helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.