Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

<CustomAction
    Id="myCustomAction"
    GroupId="PersonalActions"
    Location="Microsoft.SharePoint.StandardMenu"
    Sequence="1000"
    Title="My Link"
    Description="This is my custom link."
>
    <UrlAction Url="http://www.example.com/" />
</CustomAction>

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.)

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
Thank you. That does help. –  Jeremy Jan 7 '13 at 22:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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