Custom template only being displayed for users with admin role

Forums › Forums › Search & Filter Pro › Custom template only being displayed for users with admin role

Viewing 9 posts – 1 through 9 (of 9 total)
  • Anonymous
    #1949

    I’m having this strange issue where the custom template I’ve specified for a search form is only being displayed to users with the admin role.

    it looks like it is failing here in class-search-filter.php:

    	public function handle_template($original_template)
    	{
    		global $sf_form_data;
    		
    		if($sf_form_data->is_valid_form())

    any ideas?

    Anonymous
    #1951

    I was able to resolve my issue by changing the priority of the ‘pre_get_posts’ filter in class Search_Filter_Setup_Query

    i changed this line from:
    add_filter('pre_get_posts', array($this, 'filter_query'), 20);

    to
    add_filter('pre_get_posts', array($this, 'filter_query'), 10);

    do you think changing this priority will break something else? is there a reason why you had it at 20?

    thanks!

    Anonymous
    #1952

    btw, I think the reason changing the priority fixed my issue is because $query->is_main_query() in the filter_query method was failing

    Ross Moderator
    #1956

    Hey Morgan thanks for the update.

    The lower priority means it will be called later and after other plugin code, so I am unsure what is happening but it seems like you may have some other code that also tries to modify the template that is being used to display?

    I would like to figure out the problem with you as otherwise future updates will keep breaking for your setup!

    Thanks

    Anonymous
    #1959

    thanks Ross – agreed I’d love to sort this out too.

    i’ve got a little more info .. looks like there is a conflict with a plugin called “BuddyPress Docs” – when i disable this plugin and set the priority back to 20 on your method things work as expected

    i see several uses of pre_get_posts in the Budypress Docs code base .. but I’m a little over my head trying to figure out if one of these 2 plugins should be doing something slightly different to make it more compatible in general with other plugins

    would it be possible for you to put Buddypress and Buddypress Docs on a test site along with Search Filter Pro and see if you can replicate my problem?

    i guess Buddypress Docs must be doing something so that $query->is_main_query() fails in Search Filter Pro

    Ross Moderator
    #2108

    Hey Morgan, going to take a look at this this weekend and see what I can do 🙂

    Ross Moderator
    #2109

    Thanks for the detailed info btw!

    Anonymous
    #3503

    hey.. any thoughts on this?

    Ross Moderator
    #3778

    Hey Morgan totally slipped my mind with the last update.

    Quick question, do you use ajax to display your results? There is a new way to use Ajax which uses its own instance of WP_Query so you shouldn’t be getting in to these kinds of troubles 🙂

    Let me know anyway and I’ll do some further explaining!

Viewing 9 posts – 1 through 9 (of 9 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.