User generated content via secure zones and custom modules

I am looking for a method to automatically hide a user submitted custom module item from public display once the user has been removed from a specific secure zone.

Hi @Erik

The Custom Module item will have a property of CreatedByMemberId which you can use to then do a look-up of that CRM record and loop through their Secure Zones (or lack thereof).

Using: {% component type: "CRMContacts" %}

Make sure to include the Secure Zone data by setting the parameter includeSecureZonesInfo: "true"

You’ll also need to have the “Allow listing my contact data in the CMS” option enabled in the user’s CRM record, or have the global setting enabled for “Allow listing CRM contacts data” in: Miscellaneous Settings


So your CRM lookup might look like this inside your Custom Module item layout:

{% component type: "CRMContacts", layout: "", filterBy: "Id", filterValue: "{{this.CreatedByMemberId}}", limit: "1" collectionVariable: "userZones" %}

Then to do the check:

{% assign hasZone = false %}

{% if  userZones.items[0].id == this.CreatedByMemberId %}
    {% for zone in userZones.items[0].SecureZones %}
    {% if zone.id == "1234" %}
    {% assign hasZone = true %}
    {% break %}
    {% endif %}
    {% endfor %}
{% endif %}

Replace 1234 with the ID of your Secure Zone.

(the first IF statement here checks if the returned CRM record matches the one you are look for, because the CRMContacts component will return all records if the filter you specify doesn’t exist - so you’d end up with the wrong CRM record)

Then you can use the variable {{hasZone}} to show or hide the item:

{% if hasZone == true %}
<!-- show your layout/item -->
{% endif %}

Adam, Legend! Thank you much appreciated. I’ll give it a go. Also is there a way to automatically notify a CRM contact via system email once their secure zone access has exprired?

There is no current notification system for expired secure zones.
You could perhaps create a custom report for ‘Contacts and Secure Zones’ and sort by zone expiry date to identify recently expired contacts?
Although this would be a manual process to check the report periodically.

Thank you! Much appreciated.

Actually, if these items are being viewed online fairly frequently/med-high traffic, then you could perhaps render a hidden form when an item is blocked, which is then auto-submitted via AJAX, eg:

{% if hasZone == true %}
<!-- show your layout/item -->
{% else %}
<!-- NOTIFICATION FORM -->
{% endif %}

The form could be populated via Liquid with the CRM owner’s email so that they get the autoresponder.

You’d also want to put a check in place to only render this form if there isn’t a case file already for that CRM contact for this form (to stop it being submitted multiple times).

Hope this makes sense.
Basically, we’re utilising other visitors to the site to trigger the notification based on if an item is blocked due to an expired secure zone status.
It’s a bit of a hack :slight_smile:

1 Like

Adam,

Member signup form has field “allow lising my contact date in the cms” ticked.

Render list of items on page: {% component source: "Art News", layout: "List", sortBy: "releasedate", sortOrder: "DESC", limit: "100", collectionVariable: "itemList", type: "module", includeSecureZonesInfo: "true" %}

Custom module list layout: `{% component type: “CRMContacts”, layout: “”, filterBy: “Id”, filterValue: “{{this.CreatedByMemberId}}”, limit: “1”, collectionVariable: “userZones” %}

{% assign hasZone = false %}

{% if userZones.items[0].id == this.CreatedByMemberId %}
{% for zone in userZones.items[0].SecureZones %}
{% if zone.id == “1057” %}
{% assign hasZone = true %}
{% break %}
{% endif %}
{% endfor %}
{% endif %}

{% if hasZone == true %}

...... {% endif %}`

I have submitted an item as a member but it does not show in the list. what am i missing? thank you in advance.

Hi @Erik
In your List layout, after the CRMContact component, do you get any output when just trying to render:

<pre>{{userZones}}</pre>

Are you the member who submitted the item?

interestingly although the user can login and is associated to the zone it does not seem to show.

SecureZone is empty.

Oh right. You need to add the parameter includeSecureZonesInfo: "true" to the CRMContact component.

You are a legend. Thank you so much. It works now!

1 Like

is there an easy way to also hide the custom modile item if secure zone id equals id “X” and access to the specific zone has expired?

Perhaps not an easy way, but it’s certainly possible.
You already have the first part @Erik with the checking for Zone ID, we just need to add in the expiry date check too:

{% assign hasZone = false %}
{% assign isZoneXandExpired = false %}

{% for zone in userZones.items[0].SecureZones %}
{% if zone.id == “1057” %}
{% assign hasZone = true %}
{% elsif zone.id == “X” %}
{% assign nowSec = "now" | date: "%s" | plus: 0 %}
{% assign expirySec = zone.expirydatetime | date: "%s" | plus: 0 %}

{% if nowSec > expirySec %}
{% assign isZoneXandExpired = true %}
{% endif %}

{% endif %}
{% endfor %}


{% if hasZone == true %}
<!-- items if zone 1057 -->
{% endif %}

{% if isZoneXandExpired == false %}
<!-- items if zone X and not expired -->
{% endif %}

{% if hasZone == true and isZoneXandExpired == false %}
<!-- COMBINED CONDITION: items if zone 1057 and zone X and not expired -->
{% endif %}

I haven’t tested this code but it should be pretty close (if I’ve understood your requirements).

That worked a treat. thank you so much Adam!

1 Like

@Adam.Wilson Interestingly the code works if a member was added to the zone manually. If the member is added to the secore zone via a payment form it does not work. I can’t see why?

@Erik are you referring to the isZoneXandExpired check?
Try rendering out the full Liquid object and compare the output between the 2 different types of members:

<pre>{{userZones}}</pre>

See if there is anything different or missing with their secure zone info.

Maybe the zone expiry date is not being set correctly when registering via the form?

image

Member who has used payment form.

So there is no contact data being returned.
Do they have "allow lising my contact date in the cms” ticked?

Also, does the filtered ID 34158 match the member’s ID who is logged in?

Thank you "allow lising my contact date in the cms” ticked? was not ticked on the payment form.

I was not aware that was needed as the user had already used onother secure zone sign up form prior to payment where the "allow lising my contact date in the cms” was ticked.

It shouldn’t be needed again, but perhaps with it not being ticked on the second submission then actually turned if off.