Home › Toolset Professional Support › [Resolved] Hide content in search (in views)
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 |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
Tagged: Views plugin
This topic contains 11 replies, has 2 voices.
Last updated by lucaC-7 5 years, 2 months ago.
Assisted by: Nigel.
In my VIEWS I have some content Blocked to some users type, via "Article Groups". (See attachments)
How can I hide this articles from the search, to the same users?
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Luca
This scenario is described in the following documentation, if you could please check that: https://toolset.com/documentation/user-guides/using-access-to-hide-certain-posts-from-view-results/
If you get stuck, let me know.
Ok, I try!
Sooo...
If I put the shortcode "[wpv-post-field name='_wpcf_access_group']" in my post, they give me all different values...
This means that I haven't a grouped posts"?!
I try to better clarify my situation:
Now using the "eq" symbol, the content with a specific "group" is filtered... BUT for all the USERS, not only the ones assigned to the "post group"...
I just whant that a ROLE that CAN'T view a post (specified in Group Post, with a 404 result for example) also don't see the preview in the VIEW page!
I'm missing something!
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
OK, let me try and set this is up on my own local site and I'll update again here soon.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
So it seems that documentation only tells part of the story. It can be used to identify posts which are part of an Access Post Group, but that's it, it doesn't offer anyway to enforce the Post Group settings on the output of the View.
So, we need to combine testing for whether the current post in the loop is part of the Access Post Group, and if so, then use the toolset_access shortcode to decide whether to display it or not. (See https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/).
Because there is no 'else' clause with conditional shortcodes, we must repeat the test, once to check if the current post is in the Access Post Group (if so, apply the toolset_access shortcode) and once to check if it isn't (display anyway).
On my test site that results in the following markup in the Loop Editor (where all I am outputting is the post title as a link):
<wpv-loop> [wpv-conditional if="( $(_wpcf_access_group) eq 'wpcf-custom-group-c89b33f8b3f6f452ef6f07d397b5dcdf' )"] [toolset_access role="Contributor" operator="deny" raw="true"] <h3>[wpv-post-link]</h3> [/toolset_access] [/wpv-conditional] [wpv-conditional if="( $(_wpcf_access_group) ne 'wpcf-custom-group-c89b33f8b3f6f452ef6f07d397b5dcdf' )"] <h3>[wpv-post-link]</h3> [/wpv-conditional] </wpv-loop>
With the toolset_access shortcode, in my example I am showing the content to everyone who is not a contributor, the role I want to deny access to.
Ok, we are near the goal!
One more thing... how can I avoid that the "filtered posts" leave an empty space?!?
(see image)
My code are this:
[wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --><wpv-loop wrap="4" pad="true"> [wpv-item index=1] <div class="row "> <div class="col-sm-3"> [wpv-conditional if="( $(_wpcf_access_group) eq 'wpcf-custom-group-241b086927e8f34162e9bdbb05b04f4f' )"] [toolset_access role="commerciale_sezionali,commercale_libro,commerciale_altri_prodotti" operator="deny" raw="true"][wpv-post-body view_template="loop-item-in-docus"][/toolset_access][/wpv-conditional] [wpv-conditional if="( $(_wpcf_access_group) eq 'wpcf-custom-group-aaf4f701dced131b636b247af50799e0' ) OR ( $(_wpcf_access_group) eq 'wpcf-custom-group-ce23fd3f933350cfb826d6c0555aadc3' )"][toolset_access role="commerciale_bremet" operator="deny" raw="true"][wpv-post-body view_template="loop-item-in-docus"][/toolset_access][/wpv-conditional]</div> [wpv-item index=other] <div class="col-sm-3">[wpv-conditional if="( $(_wpcf_access_group) eq 'wpcf-custom-group-241b086927e8f34162e9bdbb05b04f4f' )"] [toolset_access role="commerciale_sezionali,commercale_libro,commerciale_altri_prodotti" operator="deny" raw="true"][wpv-post-body view_template="loop-item-in-docus"][/toolset_access][/wpv-conditional] [wpv-conditional if="( $(_wpcf_access_group) eq 'wpcf-custom-group-aaf4f701dced131b636b247af50799e0' ) OR ( $(_wpcf_access_group) eq 'wpcf-custom-group-ce23fd3f933350cfb826d6c0555aadc3' )"][toolset_access role="commerciale_bremet" operator="deny" raw="true"][wpv-post-body view_template="loop-item-in-docus"][/toolset_access][/wpv-conditional]</div> [wpv-item index=4] <div class="col-sm-3">[wpv-conditional if="( $(_wpcf_access_group) eq 'wpcf-custom-group-241b086927e8f34162e9bdbb05b04f4f' )"] [toolset_access role="commerciale_sezionali,commercale_libro,commerciale_altri_prodotti" operator="deny" raw="true"][wpv-post-body view_template="loop-item-in-docus"][/toolset_access][/wpv-conditional] [wpv-conditional if="( $(_wpcf_access_group) eq 'wpcf-custom-group-aaf4f701dced131b636b247af50799e0' ) OR ( $(_wpcf_access_group) eq 'wpcf-custom-group-ce23fd3f933350cfb826d6c0555aadc3' )"][toolset_access role="commerciale_bremet" operator="deny" raw="true"][wpv-post-body view_template="loop-item-in-docus"][/toolset_access][/wpv-conditional]</div> </div> [wpv-item index=pad] <div class="col-sm-3"></div> [wpv-item index=pad-last] <div class="col-sm-3"></div> </div> </wpv-loop> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]Effettua una nuova ricerca...[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end]
Thanks
New threads created by Nigel and linked to this one are listed below:
https://toolset.com/forums/topic/bootstrap-grid-leaves-blanks-when-conditionally-hiding-some-posts/
Hi Nigel,
I hope today we can solve completely my problem and close this ticket!
See you later!
Luca
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Luca
You can't when using the Bootstrap grid this way.
The shortcodes in the Loop Editor generate the markup required for the Bootstrap grid, and the slots for the grid are generated even when you don't output anything in that slot.
You need to replace the standard Bootstrap grid to allow for this possibility.
As this forum thread was about applying the Access Post Group settings to a View output, let's close here and I will split this question about the grid display into a new thread.
Ok, I'm waiting for the new thread
My issue is resolved now. Thank you!