Get current user

Is there a way to get the currently logged in user, from within a custom module? Hubspot has default variables that return information about the current page, for example {{ content }} would return the content of the current post/page. Is there something similar - along the lines of {{ current_user }} that can be used to get information about the current user?

Hi @jillii :waving_hand:

I could be way off, but have you tried using the “request_contact” variable (as per this doc). I stumbled across it when reading the HubSpot Developer Blog post “How to create a header navigation that adapts to a logged-in contact”.

I hope this proves useful. Please let me know if you have any follow-up questions.

I saw that too, and it definitely looked promising. It’s returning empty (shown below), even though I’m looking in my cookies and seeing that hubspot is tracking me - so it should return something…

(ContentRequestContact: {company={}, companyDefaults={}, companyWithDefaults={}, companyWithoutDefaults={}, contact={}, contactDefaults={}, contactVid=null, contactWithDefaults={}, contactWithDefaultsPreview={hubspot_owner_id={}}, contactWithoutDefaults={}, dealId=Optional.empty, emailCampaignId=null, emailPortalPair=null, idType=null, identifier=null, isHubspotUser=false, isLoggedIn=false, isSsoLogin=false, lazyAccountWithDefaultsForPreview={{account}}, lazyCompanyWithDefaults={}, lazyCompanyWithDefaultsForPreview={{company}}, lazyCompanyWithoutDefaults={}, lazyContactWithDefaults={}, lazyContactWithDefaultsForPreview={{contact}}, lazyContactWithDefaultsPreview={hubspot_owner_id={}}, lazyContactWithoutDefaults={}, lazyOwnerDefaultsWithDefaultOwnerLookup={}, lazyOwnerWithDefaults={}, lazyOwnerWithDefaultsForPreview={{owner}}, lifecycleStage=null, lifecycleStageId=null, listMemberships=[], owner={}, ownerDefaultsWithDefaultOwnerLookup={}, ownerWithDefaults={}, qualified=false, resolvedContact=Optional.empty})