[SalesForce] how to get the user logged in in community

I need to get the Id of the user logged in community for Visualforce Page. How can I get the login user in salesforce community and use in Visualforce Page?

Best Answer

In Visualforce, you can reference the User global variable.

{!$User.Id}

In Apex, UserInfo methods should work just fine in the context of communities:

Id runningUserId = UserInfo.getUserId();
Related Topic