Skip Navigation

[Resolved] Restrict access to CPTs using User proxy to post relationships

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by benv-2 6 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1088522

Dear Christian,

Thank you for your help!
I'll create a new support-call on how to reply through e-mail.

I've one question left on this ongoing subject:
I created an Template for a page, which shows the fields of a single Contact post.
The Engineer can press on a link in the Contacts view and open a single Contact.
In the view, the engineer can only see the contacts that are bound for him through the m2m relation between Place and Contact.
Is it also possible to restrict a single page for the bound engineer?

For example:
Engineer A is bound to place New York. In the contacts view he can only see the contacts from New York.
He tries to modify the slug to e.g. /contact/test12345. This contact isn't bound to New York, but he can still open this one by modifing the slug.

#1088523
1088514-Single_entry_restrict.png

Reference image from previous post.

#1088574

Is it also possible to restrict a single page for the bound engineer?
Toolset Access gives you the ability to restrict posts based on Post Group or User Role. However, in your case I don't think either of these is useful because the Engineer is associated with Places using post relationships. Instead, I think you must use conditionals to show and hide content in each post. The URLs will not be restricted, but the contents of the posts will be hidden.

You can use the custom shortcode in a conditional and compare it against the post reference field value, like this:

[wpv-conditional if="( ARRAY([engineer-place-ids]) eq $(wpcf-your-reference-field-slug) )"]

This Engineer can access the post [wpv-post-title].

[/wpv-conditional]

Add the "wpcf-" prefix to your reference field slug in the conditional, and be sure to register engineer-place-ids in Toolset > Settings > Third-party shortcode arguments.

#1088591

This works great, exactly what i need! Thank you!