I was wondering if there was a way to get certain information of a currently viewed User Profile in APEX?

Here's a sample scenario:
1. I have a community page with a Group List
2. I go into a Group, then I click on a User on the Group.
3. While viewing that particular User, I wanted to manipulate certain data in my component based on currently viewed User.


Adding a reference image as to which User Profile I am talking about. enter image description here

1 Answer 1


You can find the Profile Id and other info about the running user with the UserInfo class. If you want to know the Profile Id of the currently logged in user, use UserInfo.getProfileId();

If you want to know about some other user you can query the User sobject:

select id,.. from user where id =: userId
  • Thanks for the reply. This class seems to return UserInfo about the context user. I think that means, the user who is currently viewing the community, yes? I was hoping to get the user info of the currently viewed user profile not the current user profile.
    – kev_panda
    May 19, 2017 at 19:46
  • what is url of community when you are viewing a user? May 20, 2017 at 7:13
  • the url of the community for viewing a user profile looks something like this: mycommunity.developer-edition.na3.force.com/mycommunitysample/s/… please note this url doesn't actually work.
    – kev_panda
    May 22, 2017 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .