Skip Navigation

[Resolved] Content restricted with Access still shows up in a view/archive

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 5 replies, has 2 voices.

Last updated by Ronald 7 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#576301

I am trying to:

Restrict Content from a site so that only a specific user role can access it. I used Toolset's Access plugin to do this and while I cannot view the content while logged out, it still shows up in searches/views

Link to a page where the issue can be seen:

hidden link

I expected to see:

Nothing to show up

Instead, I got:

That restricted content showing up

#576353

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - inside the view you can either use [wpv-conditional] or [toolset_access] shortcode to display conditional content.

For example - :

[wpv–conditional if="( '[wpv-current-user info='role']' eq 'administrator' )"]
 
Display your custom fields for administrator role
 
[/wpv–conditional]

More info:
https://toolset.com/documentation/views-shortcodes/#wpv-conditional
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

[toolset_access] shortcode example:

[toolset_access role="administrator" operator="allow"]
your content 
[/toolset_access]

[toolset_access role="your-role-name" operator="deny"]
your content 
[/toolset_access]

#576527

Well if I wrapped the whole view in a conditional access shortcode, the whole view will only show up if you are that specific role. I need the view to be visible to all, but specific content that is for a specific role to only show if the person who is viewing the same view is logged in.

Does that make sense? Lets say I have a blog view and out of 100 blog posts, 10 posts are restricted unless you have a certain role. I dont want those 10 to show up in the blog view unless you are logged in as that specific role.

As of right now, those 10 show up in the view, but thanks to Access if I click on one, it gives me a 404. my goal is to get them to not show up at all. Your solution above sounds like you are trying to show/hide the whole view unless you are that specific role which is not what I need.

Any ideas?

#576532
Screen Shot 2017-10-05 at 8.48.17 AM.png

Oh btw, the specific content in question is being controled by an Access Post Group as seen in the screenshot below.

#576536

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I think you misunderstood the concept here.

You can use both [wpv-conditional] and [toolset_access] shortcode within the view's loop output editor. So, whatever information you are displaying from view's loop output editor (within the view's loop) that should be wrapped with [wpv-conditional] and [toolset_access] shortcode.

For example:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
                          [wpv–conditional if="( '[wpv-current-user info='role']' eq 'administrator' )"]
  
                                        [wpv-post-link]
  
                            [/wpv–conditional]
                                                     
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

So with above view - the [wpv-post-link] will be displayed to only users who is having role = administrator.

I hope its clear now and above example will help you to resolve your issue.

#576600

No, that still wouldnt help, but I figured out a way to add a taxonomy and only remove those by excluding the taxonomy through a filter on the view.