Is there any way that i can show a web part only for current logged in user .I want to achieve this on an out of the box content editor web part .Please suggest me

  • What do you mean by 'current logged in user'? The user adding the web part? A specific user? Any logged in user (not anonymous)? And what do you want to show this user? – Per Jakobsen Aug 17 '12 at 20:22
  • I mean for example if i log in to the site that web part should be shown to me only .We have this requirement in mysite as in person.aspx page we are adding a content editor web part which will have a link to external application but when some one is searching for this user using profile search they are also seeing this web part .And we want to prevent this one – Anil Aug 17 '12 at 20:30
  • How do you currently add the web part to the page? – Per Jakobsen Aug 17 '12 at 20:58
  • I am a site collection admin so i will just edit the page and add the content editor web part .I am not sure whether i am answering your questoin. – Anil Aug 17 '12 at 21:02

yes you can, you make what you want in the content editor webpart and surround it with an if function that checks to see if the user is authenticated or not, If they are then do the code and show what you want to the authenticated user and if not an authenticated user do nothing, basicly show nothing or a message.


Its better to make your own webpart in visual studios c# or vb.net and check the user is authenticated like this and then https://stackoverflow.com/questions/1336381/sharepoint-how-to-authenticate-from-c-sharp and do the same logic. The only difference is you would have what you want to do in the creatChildControls and put everything in:

 using (SPWeb web = site.OpenWeb()) 
    // put all your code here to only show to authenticate users

There is no way to get a standard web part added to the common person.aspx to only show for the "owner" of the profile page.

In the general case need a custom webpart which only shows itself when it's the owner, but as far as I understand in your case there is nothing secret in the content you want to show, you just only want to show it on the persons own page, in that case you could include JavaScript to show/hide a section based on it being the same person logged in.


With a Content Editor Web Part you should be able to do Audience Targetting if you only want to display the content to a certain group or groups. You can then target your web part towards that particular audience. (e.g. Managers, Viewers, etc.), and it will only display for those select user groups.

You could create a SharePoint group for just your self, if you wanted to limit it to one person.

  • 1
    He wants to show the infomation to all users, but just only when they are seeing their "own" person.aspx page. – Per Jakobsen Aug 18 '12 at 8:39
  • @Quinn this wont work on my site. – Luis Valencia Feb 26 '14 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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