Skip Navigation

[Resolved] Displaying Content Based on Access Posts Group

This support ticket is created 4 years, 8 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.

Our next available supporter will start replying to tickets in about 1.32 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by Luo Yang 4 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#1576323

Tell us what you are trying to do?
Using a view, I'm trying to display the posts that a user-role has access to based on roles assigned in Access Posts Groups.

Is there any documentation that you are following? https://toolset.com/documentation/user-guides/access-control/using-access-to-hide-certain-posts-from-view-results/

I'm able to output the group id and I have my conditional statements in my View as follows:
[wpv-layout-start]

[wpv-items-found]

<!-- wpv-loop-start -->
<wpv-loop wrap="1" pad="true">
[wpv-conditional if="( $(_wpcf_access_group) eq 'wpcf-custom-group-6a73bd885214879e8ea0c34a7acf174c' )"]
[wpv-post-title]
[wpv-post-body view_template="None"]
[/wpv-conditional]

[wpv-conditional if="( $(_wpcf_access_group) eq 'wpcf-custom-group-5720b93f882189a20e69a14e70cc76f3' )"]
[wpv-post-title]
[wpv-post-body view_template="None"]
[/wpv-conditional]
</wpv-loop>
<!-- wpv-loop-end -->

[/wpv-items-found]

[wpv-no-items-found]
[wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

However, both results are being output, and there should only be 1 (again, based on the user roles assigned in Post Groups).

What is the link to your site? hidden link

#1576491

Here's a better link: hidden link

#1576647
group-filter.JPG

Hello,

I have tried it in my localhost, the shortcodes [wpv-conditional] ... [/wpv-conditional] work just fine.

And in your case, since you don't want display those posts of specific 'post groups' at all, it is recommended to user query filter instead of [wpv-conditional] shortcode, for example, you can edit the post view you mentioned above, in section "Query Filter", add a custom field filter:
Select items with field:
_wpcf_access_group is a string equal to wpcf-custom-group-5720b93f882189a20e69a14e70cc76f3

See screenshot group-filter.JPG