Skip Navigation

[Resolved] Views AJAX search doesn't load when you're not logged in

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)

This topic contains 3 replies, has 2 voices.

Last updated by MichaelW8226 1 year, 8 months ago.

Assisted by: Nigel.

Author
Posts
#2563337
2023-02-28_18-22-07.png

I am trying to:

Search using the text search in Toolset Views.

Link to a page where the issue can be seen:

hidden link

I expected to see:

See attached screenshot of what the intended result is.

Searching for "maryland" returns no results when your not logged in. As an administrator, it works fine. There is no specific access control logic or anything implemented. It also works when I use the full page refresh but fails when it's using AJAX.

Instead, I got:

It almost looks like the form is broken or disconnected. It doesn't load anything including the no results found message.

We have a couple versions of this website running so I need to know how to fix it.

#2563593

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

I visited your link and tried to enter a search term, but I see in the browser console that the request shows a 302 redirect to hidden link

I suspect that one of your other plugins might be the cause, e.g. your Redirection plugin.

Try disabling other plugins (starting with obvious ones like Redirection) to see if you can find which is responsible, and then check whether the settings of that plugin can be changed so as to not provoke the problem.

#2563945

Hi there,

I'm not sure where the redirect is coming from but I disabled every plugin except the toolset one and we're still seeing the same issue. It works when logged in but not as a guest (not logged in).

#2563953

The issue was a php function preventing users without administrator access from visiting the WordPress dashboard. I found an updated version that excluded AJAX calls from the redirect.

Here's the updated version incase this comes up for someone else.

add_action( 'init', 'blockusers_init' ); function blockusers_init() { if ( is_admin() && ! current_user_can( 'administrator' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { wp_redirect( home_url('/franchise-dashboard/') ); exit; } }