I’m building a Member dashboard section of a client site where the members log in, then I want to display properties from the ‘companies’ object on that page for them to review/update.
I’m able to initiate the login through the ‘contact’ object, but having a hard time figuring out how to initiate the login through, and then display any properties from the ‘companies’ object.
the “function” you’re looking for is called membership areas. They are available in CMS Hub Enterprise. If you don’t have CMS Hub Enterprise you can create something similar with lists and a password protected page.
Also a bit of promotion: If you’re interested in learning more about membership areas - there will be a HUG(HubSpot User Group) event on the 18th of January about this topic.
I’m actually already using this membership system to log members in. I’ve got that working. I’m just having trouble displaying the needed information on the Member Dashboard page from the ‘company’ object.
I have made a little progeress since posting the original question, however. Here is a snipet of test code. Am I on right track by using ‘associated_objects’ to display company properties, based on the vid of the logged in conatact? Is that how I should be approaching this? So far, this is the only thing I’ve gotten to half-way work. However, it still won’t display the ‘comany_name’ for some reason, or the ‘company_logo’.
{% if request_contact.is_logged_in %}
{% set membership_contact = crm_object('contact', request.contact.contact_vid, 'firstname,lastname') %}
Welcome back, {{ membership_contact.firstname }} {{ membership_contact.lastname }}
{% set associated_objects = crm_associations(request.contact.contact_vid, "HUBSPOT_DEFINED", 1, 'limit=100&member_status=Current', 'company_name, company_type, company_logo, image, business_type, materials, website, phone, city, state, country, description, contact_id') %}
<h3>Companies Associated With Contact</h3>
{% for company in associated_objects.results %}
<p>Company Name: {{company.company_name}} {{company.business_type}} </p>
<p>Phone: {{company.phone}}</p>
<p>Descr: {{company.description}}</p>
<p>
<img src="{{company.company_logo}}">
</p>
{% endfor %}
<a href="/_hcms/mem/logout">Logout</a>
{% else %}
<a href="/_hcms/mem/login">Log In</a>
{% endif %}