SharePoint 2013: Current User Name using XSL and ParameterBinding

Sometimes you want to make parts of your form available for a certain logged in user or the opposite you want to hide some parts of your form for a special user.

In my case I want to test if a certain person field equals the current logged in user and if it is true I want to display some extra stuff.

There are only 3 Steps left to achieve your goal:

  1. Add two lines under <xsl:param name=”dvt_apos”><xsl:param name=”UserID” />
    <xsl:param name=”LogonUser”/>
  2. Add two lines to your ParameterBinding<ParameterBinding Name=”UserID” Location=”CAMLVariable” DefaultValue=”CurrentUserName”/>
    <ParameterBinding Name=”LogonUser” Location = “ServerVariable(LOGON_USER)” />
  3. Now use some code to decide if current user is equal to a certain person field and do some stuff. Change @MyPersonField to your needs.

        <xsl:when test=”contains(@MyPersonField, $UserID)”>
            Display Current Logon User ID:    <xsl:value-of select=”$LogonUser”></xsl:value-of>
            Display Current Logon User Name: <xsl:value-of select=”$UserID”></xsl:value-of>
            … do other stuff …

..:: I like SharePoint ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

About Dennis de Vries 34 Articles
Loving SharePoint, Social Media and like to work together with creative people all over the world.


  1. How can I do this in 2010 Sharepoint I want to just display the current username in one of my fields? I do not want to wait for the form to render. I would like to do this in the new item form so a user sees thier name on the new item form.

    • Hi, if you could use JQuery and SPServices then the following option is possible:

      1. Add SPServices and JQuery to your Site


      2. Use document ready function to load username

      $(document).ready(function () {
      var thisUserName = $().SPServices.SPGetCurrentUser({
      fieldName: "Title",
      debug: false

  2. I have been using this test=contains(@user_x0020_field,$UserID) with a lot of success but found a problem. This test is failing when the user name contains an apostrophe (O’Leary). I’ve displayed the fields to confirm that both names contain the apostrophe but the test is failing.

    Have you experienced this issue and, if so, how did you work through it?

Leave a Reply

Your email address will not be published.