Skip Navigation

[Resolved] Relevanssi search results visible on front end

This thread is resolved. Here is a description of the problem and solution.

Problem: I have used Access to hide posts from Guest users, but I would can still see post information in search results. I would like to hide this information from Guest users.

Solution: A WordPress Archive is used to display search results. That archive is built in the legacy shortcode version, so you can use Access Control shortcodes in the archive's contents to suppress any visible information. The syntax is as follows:

[toolset_access role="Guest" operator="deny"]
  Guests will never see anything inside this shortcode.
[/toolset_access]

If the archive is built using the Blocks Editor, you may use conditional blocks to achieve the same effect.

Relevant Documentation:
https://toolset.com/course-lesson/using-toolset-conditional-block/

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.

Our next available supporter will start replying to tickets in about 0.82 hours from now. Thank you for your understanding.

Author
Posts
#1783997

Our Website is only for registered users.
For this we are using toolset access.
I only recently was aware that the search result from relevanssi are visible anyway.

I searched the forum and found the following articles but I had no success in getting the result of the relevanssi from being displayed.
https://toolset.com/forums/topic/relevanssi-allows-users-to-see-other-users-private-posts/
https://toolset.com/forums/topic/remove-relevanssi-results-from-front-end/

I thought initially that my view for the search result (layout-for-person-archive) is being controlled by access.

You can check the current behavior at
hidden link

#1784001

I also was looking at relevanssi for some code (functions.php)
but had no luck in getting it to work.
hidden link
hidden link

#1784711

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I thought initially that my view for the search result (layout-for-person-archive) is being controlled by access.
Hello, as you may have read one of your other ticket links, Access does not filter the output of Views so the post type settings and applied post groups have no effect on the results shown in a View. With that being said, I might be able to help you hide posts in the search results from Guest users if you can provide a bit more information by answering the following questions:
- Do you want all posts of all types and all post groups hidden from Guest Users in search results pages, or are there some specific posts or specific post types that should remain searchable when logged-out?
- Some of the links you provided mention "protected" posts, also referred to as posts published privately in WordPress. This built-in WordPress feature makes each private post visible only to the logged-in post author and logged-in site administrators. Are some or all posts on your site published privately? Should this private setting have any impact on the search results seen by Guest Users?
- Can you show me the details of the Layout and WordPress Archives assigned to Search Results? Please take screenshots in wp-admin so I can see the Layout cells responsible for this page. Please also take screenshots of the WordPress Archive cell contents so I can review your setup.

If you would prefer to allow access to your wp-admin area, I will be glad to take a closer look for myself. Please provide login credentials in the private reply fields here. I will review your setup and give you some feedback.

#1788053

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Okay it seems that this WordPress Archive is responsible for the design of the search results page:
hidden link

I have added some Toolset Access control shortcodes that will prevent content from being displayed to Guests. The syntax is:

[toolset_access role="Guest" operator="deny"]Guests will never see this text.[/toolset_access]

The new code from the updated loop editor is shown here:

[toolset_access role="Guest" operator="deny"]<div class="row">
	<div class="col-sm-4"></div>
	<div class="col-sm-4">Es gibt <h8>[wpv-found-count]</h8> Eintr├Ąge mit diesen Kriterien</div>
	<div class="col-sm-4"></div>
</div>[/toolset_access]
[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop wrap="4" pad="true">
		[wpv-item index=1]
		[toolset_access role="Guest" operator="deny"]<div class="row ">
			<div class="col-sm-3">[wpv-post-body view_template="WordPress Archive - Schleifen-Objekt"]</div>[/toolset_access]
		[wpv-item index=other]
		[toolset_access role="Guest" operator="deny"]<div class="col-sm-3">[wpv-post-body view_template="WordPress Archive - Schleifen-Objekt"]</div>[/toolset_access]
		[wpv-item index=4]
		[toolset_access role="Guest" operator="deny"]<div class="col-sm-3">[wpv-post-body view_template="WordPress Archive - Schleifen-Objekt"]</div>
		</div>[/toolset_access]
		[wpv-item index=pad]
		[toolset_access role="Guest" operator="deny"]<div class="col-sm-3"></div>[/toolset_access]
		[wpv-item index=pad-last]
		[toolset_access role="Guest" operator="deny"]<div class="col-sm-3"></div>
		</div>[/toolset_access]
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]Leider nichts gefunden![/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

I also noticed there was a missing closing div tag in the pad-last item, so I replaced it. The code highlighter will show this closing div tag as an error, but it is actually required here. You can disregard the red highlight. Now guests see no search results, as shown in the attachment. If you would like to add a message, you can edit the WordPress Archive and place your message text somewhere outside the wpv-loop tags. Use the Access button above the Loop Editor to create Access Control shortcodes which will allow you to display text only to Guest Users.

#1788629

Wow, thank you for your brilliant solution. Many thanks for your help!