You need to sign in to do that
Don't have an account?
After using "log in to community as user" how can I use Apex to get the original Salesforce user?
I have a need to get the User object for the user who logged into SFDC so that I can use it in my community. After using "log in to community as user" how can I use Apex to get the original Salesforce user?
However you can use some trick. Idea is the following:
We login in as community user from Contact page. At this page we have to save somewhere salesforce user ID and community user ID. It could be custom settings, web storage or something similar. In landing community page we can read this data and to detect user ID.
Of course tricky solution has a lot of limitations. For example you have to separate real community user and "fake" ones (who have logged from Contact page).
All Answers
However you can use some trick. Idea is the following:
We login in as community user from Contact page. At this page we have to save somewhere salesforce user ID and community user ID. It could be custom settings, web storage or something similar. In landing community page we can read this data and to detect user ID.
Of course tricky solution has a lot of limitations. For example you have to separate real community user and "fake" ones (who have logged from Contact page).
Check it:
https://salesforceprofs.com/how-to-detect-log-in-to-community-as-user-in-apex/