Skip Navigation

[Resolved] Suspect incompatibility between shortcode wpv-found-count and access

This support ticket is created 7 years, 3 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
- 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 5 replies, has 3 voices.

Last updated by romanB-3 7 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#558227

Hello,
I am using views with a table display, where each line is tested before to be printed :

	<!-- wpv-loop-start -->
          <wpv-loop>
          [wpv-conditional if="( '[wpv-current-user]' eq '[wpv-post-author]' )"]
			<tr>[wpv-post-body view_template="Loop item in Toutes les demandes en cours pour un produit"]</tr>
          [/wpv-conditional]
          [wpv-conditional if="( '[wpv-current-user]' ne '[wpv-post-author]' )"]
          	[toolset_access role="RespAchats" operator="allow"]
			<tr>[wpv-post-body view_template="Loop item in Toutes les demandes en cours pour un produit"]</tr>
          	[/toolset_access]
          [/wpv-conditional]
		</wpv-loop>
    <!-- wpv-loop-end -->

If the current user is the post author, then it show the line, if he is not, then he must have "RespAchats" role to see it.

The conditional shortcode works great, and if the view loads no result, both the wpv-found-count and wpv-items-count return "0".

But the access shortcode doesn't work that way, since it doesn't show the line that he shouldn't, BUT it counts them as if they were there : then, both wpv-found-count and wpv-items-count return the total number of results, including the ones hidden by access.

Thank you.

#558286

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Roman,

1. Can you try to add the condition directly inside the Content Template (over the content shortcodes) and see if it works that way?

2. And what happens when you test this with a native WP role (such as Author, Contributor, etc)?

3. wpv-found-count and wpv-items-count return "0".
==> I can't see these anywhere in the View loop you have provided, where and how you are using it?

4. There could be a better approach to do that, can you please explain with an example what you are trying to achieve.

Please also provide temporary website WP-admin and FTP info for your site so I can see your setup. Your next answer will be private which means only you and I have access to it.

=== Please backup your database and website ===

✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.

✙ Please add the Links to the [Custom Role, View / CT] Edit Screen and [Page link, etc] where we can see the issue.

Thank you

#559450

Dear Roman,

It is expected result: the views shortcodes [wpv-found-count] and [wpv-items-count] return the total number of results.

Because of these:
The shortcodes [wpv-found-count], [wpv-items-count], [wpv-conditional] and [toolset_access] run after the view's query get result.

So, the shortcodes [wpv-conditional] and [toolset_access] can not modify the result of [wpv-found-count] and [wpv-items-count].

In your case, you still need to display another content template for those hidden posts, so I don't think there is any built-in feature within Views can achieve what you want.

#559481

OK, I understand better now.

Would it be possible to make a feature request that would allow to hide all content (including filters) if a view has no result ?

Thank you.

#559789

As your request, I forward it to our supporter who is responsible for the feature request of Views plugin, but there isn't any ETA for it, I suggest you subscribe to our blog to get the updated news.
https://toolset.com/blog/

#559859

Thank you.