The posts under 'Responses form the Community' are child posts of the original post, which have been added through CRED forms. The first reply is part of the post group 'Private' and should not be visible to the general public. If you view its direct link hidden link then it is restricted.
However, the view is not respecting the access rules, and is showing the post despite it being restricted. How can I get the views on this site to respect the rules imposed by Access with respect to Post Groups?
Thanks for your reply. What I need is straightforward - that the View respect Post Group rules. So, if a post is hidden for guest access, that it does not show in the view results to unregistered users, but that it does show to registered users.
So in my case I have a tick box field for 'private' which then assigns a post to the 'private' post group. I run a kind of membership site with 3 levels of members - if a post is assigned to the private group I would like only those registered users to see the post, and not guests.
So on this page: hidden link the first post 'Prueba 2' (it's just demo nonsense content) should not show to non-registered users, but should show to registered users.
So in basic form I'd like the View output to respect the rules of the post groups. Is there a way to achieve this?
It's particularly important because here hidden link the first 'response' post is a private post (in the post group) but the view is showing the post in full to unregistered users, because it ignores the post group rules.
Thanks Minesh, but your code has hidden the relevant post for ALL users.
The posts in this post group 'Private' need to be hidden for all users except the authorised groups of users (as per the privileges in the post group).
For instance, this is the code I'm using to hide the post form from non-registered users, which lists the three user groups that should be able to see the post :
So, if you want to go role base - you can add same conditional statement and just replace the form shortcode with your views shortcode and remove the filter I've added and the custom code I've added.
I'm a bit confused. The entire point of my support thread is to have the View deliver content based on the user role, conditional on whether a post is part of a post group. I can easily make the View hide the 'private' content because post group membership is set up a field in the post, so I can use a simple query filter for that. But then the post is hidden for all users, just like your filter.
Using shortcodes within the view does not work very well because they need to go in the loop template, and then the row is still generated and the design breaks down, because there will be empty rows.
I'm looking at your code again - is there a way to modify it to add the condition of checking for role base? So the filter checks for the the private field or post group membership AND checks for user role?
So if the private field is ticked it filters out the post unless the user is one of the three groups?
As per your request - we are checking to which roles we give read permission but again it applied to the whole view not per post but this will give you idea how it works. There is no other solution as there is no such feature exists.
Thanks - are you saying that it doesn't work? Surely this is something that is a common issue for many people? This means a big part of Access doesn't work, because the whole point of Toolset is to present posts through Views.
Ok - I think finally, following solution should work for you.
What we are doing is - we are fetching all the private posts IDs and also checking with the current user role, if current user role is available within the private post group then we it will exclude that post ID from the query.
I would like to have the same code apply to the following views:
1054, 1120, 1118, 1052, 846, 1011, 1093, 1472, 865, 1469, 1451, 1464, 1464 etc. - there is quite a long list.