function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Admin DNAAdmin DNA 

get ip client for guest user in community

Hi, is there a way to get the ip address of the connected guest user?
I try the below code but it works for the logged user but returns null for the guest users:
public static String GetUserIPAddress() {
string ReturnValue = Auth.SessionManagement.getCurrentSession().get('SourceIp');

I also try with a callout but it returns ip of salesforce server
Khan AnasKhan Anas (Salesforce Developers) 

Greetings to you!

You can use API to capture IP Address.

Please refer to the below links which might help you further with the above requirement.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Admin DNAAdmin DNA
Hi, I've already tried this way with a apex callout to trackip but it returns the ip of saelsforce server. Is there a way to use it in lightning community withouth apex?
Thank you