Hi @ilanio,
First of all, I want to mention that the functionality you are looking for and that you’ve also mentioned, “Exclude Restricted Posts from Queries”, is available in the Free version, and there is no need for any paid versions.
What is the search functionality that you’re using, in which the restricted page still appears in the search result? I’m asking this since I made a test while using the default WordPress search block: https://wordpress.com/support/wordpress-editor/blocks/search-block/, and the restricted page was correctly excluded from the results.
Best regards,
Thread Starter
ilanio
(@ilanio)
Hi @alexandrubodea and thanks for the speedy reply!
Glad to hear that the free version does what I’m looking for.
I’m using Elementor for the search widget and I’ve also got Ivory Search. However, the behavior is the same even with Ivory Search deactivated.
Thanks!
Hi @ilanio,
Just to be sure:
- Could you please edit the page where you have this search issue -> and send a screenshot from Elementor where it can be seen the exact Search widget you’re using (for example, why searching for the widget on the left Elementor menu)?
- Could you please go to your site’s Dashboard -> Plugins -> Installed Plugins -> and send a screenshot with everything you have installed related to Profile Builder (make sure the plugin version can be seen)?
- Could you please go to your site’s Dashboard -> Profile Builder -> Settings -> Content Restriction -> and send a screenshot from there (please make sure all the settings from that page can be seen)?
Note: You can use a site like https://snipboard.io/ to share the screenshots.
Thread Starter
ilanio
(@ilanio)
Hi @alexandrubodea,
I think we can rule out Elementor, because the behavior is the same without it. I did a basic search with the “?s=query” parameter in the URL, and you can see the results: https://snipboard.io/HRcq8n.jpg
As you can see, the “Calendar for Registrars” page, which should be hidden completely, appears with a message “You must be logged in to view this content”. Here are the screens from the Profile Builder pages you requested: https://snipboard.io/yW72LP.jpg and https://snipboard.io/ehlYSq.jpg
However, I think I found the problem. Line 695 of profile-builder/features/content-restriction/content-restriction-filtering.php is the following:
$args[‘posts_per_page’] = get_option( ‘posts_per_page’ );
In this case, posts_per_page is 10. But we have almost 200 pages in our system. And only the first 10 are being used to augment “post__not_in”, which excludes the restricted posts. As a result, “post__not_in” never includes the pages that are further down on the list. If we change that line to:
$args[‘posts_per_page’] = -1 ;
…then it seems to work well (screenshot: https://snipboard.io/zB5TXG.jpg). I’m not sure if this breaks anything else, but I don’t see why it should. After all, it just means we are constructing a more complete list of the pages to be excluded.
What do you think?
Thanks,
Ilana 🙂
Hi Ilana,
Thank you for reporting this and for your detailed message!
I created a task so that the development team can properly investigate this and come out with a solution in a future plugin update.
Note: For your solution, it should work fine; the only downside is that it might be a bit slower (but that should be ok).