Page 1 of 1

S2Member and Wordpress Live Search

PostPosted: April 11th, 2011, 2:24 pm
by vitorclaw
Hi, I`m using s2Member and daves live search plugin.

I already tried to apply the s2Member filters to the plugin search core but it doesn`t work. Private content still appearing for everyone.

Is there any kind of function to prevent this kind of behavior?

Thanks

Re: S2Member and Wordpress Live Search

PostPosted: April 12th, 2011, 2:38 am
by Cristián Lávaque
Hi. :)

Have you tried the alternative views settings? WP Admin -> Genearl Options -> Alternative View Protection

Re: S2Member and Wordpress Live Search

PostPosted: April 12th, 2011, 8:13 am
by vitorclaw
Hi Cristián thanks for your reply, yes i already tried to change this setting but didn`t work. :(

Re: S2Member and Wordpress Live Search

PostPosted: April 12th, 2011, 11:11 am
by Cristián Lávaque
I guess that search plugin is not working with s2Member's protection, then.

You could probably implement it the access check using a function from the Advanced Query Conditionals. You can read about them here WP Admin -> s2Member -> API / Scripting -> Advanced Query Conditionals.

The developer of that plugin may be interested in having it work with s2Member and help you.

Re: S2Member and Wordpress Live Search

PostPosted: April 12th, 2011, 2:56 pm
by vitorclaw
Hey Cristián, already tried to contact him, but i got no response until now. I`m sure that applying one of the filters to the live search plugin will fix the problem, I`ve already tried to apply it but with no success, i`ll take a deeper look at it if I get it working i`ll post it here. If someone have time to help me with that i would appreciate.

Re: S2Member and Wordpress Live Search

PostPosted: April 12th, 2011, 9:04 pm
by Jason Caldwell
Enabling s2Member's Alternative View Protection should work on this. Have you tried setting Alternative View Protection to "All" instead of just for search results? A custom search plugin may not register itself within WordPress Conditionals like: is_search(), but if you set Alternative View Protection to "All", it should work. In other words, s2Member might be unable to detect that these are search results, but setting Alternative View Protection to "All" would eliminate that issue for you.

Also, be sure that you test while logged-out. Or, while logged-in as a Member, NOT an Administrator.

If all else fails, open DavesWordPressLiveSearchResults.php, and find this section:
Code: Select all
        $wpQueryResults->query(array(
          's' => $_GET['s'],
          'showposts' => $maxResults,
          'post_type' => 'any',
          'post_status' => 'publish',
        )); 

Change it to:
Code: Select all
attach_s2member_query_filters();
        $wpQueryResults->query(array(
          's' => $_GET['s'],
          'showposts' => $maxResults,
          'post_type' => 'any',
          'post_status' => 'publish',
        ));
detach_s2member_query_filters(); 

Re: S2Member and Wordpress Live Search

PostPosted: April 12th, 2011, 9:50 pm
by vitorclaw
Hi Jason, thank you so much for answering my question. Unfortunatly none of those solutions worked. I tested it as admin, as member and as guest, but I`m still able to see the private posts on the search queries even with the query using the s2member filter. And I also tried to use all of alternative view protection options. Weird behaviour :(

Re: S2Member and Wordpress Live Search

PostPosted: April 12th, 2011, 9:57 pm
by Jason Caldwell
OK. Thanks for reporting back. If you have time, can you please email the plugin developer and point them to the post above? Perhaps they can chime in here and offer some assistance. viewtopic.php?f=4&t=3087&p=9635#p9627 * We'll continue to investigate in the mean time.

Re: S2Member and Wordpress Live Search

PostPosted: April 12th, 2011, 10:19 pm
by vitorclaw
Hey Jason, just sent him a pm on twitter and an e-mail, thanks for your concern :D

Re: S2Member and Wordpress Live Search

PostPosted: April 12th, 2011, 10:55 pm
by Jason Caldwell
Thank you!
Also, can you please confirm that you tried this?
Code: Select all
attach_s2member_query_filters();
        $wpQueryResults->query(array(
          's' => $_GET['s'],
          'showposts' => $maxResults,
          'post_type' => 'any',
          'post_status' => 'publish',
        ));
detach_s2member_query_filters();  

Re: S2Member and Wordpress Live Search

PostPosted: April 12th, 2011, 11:08 pm
by vitorclaw
Hi Jason, yes I did
Code: Select all
      attach_s2member_query_filters();
         $wpQueryResults->query(array(
            's' => $_GET['s'],
            'showposts' => $maxResults,
            'post_type' => 'any',
            'post_status' => 'publish',
         ));
      detach_s2member_query_filters();
        $this->searchTerms = $wpQueryResults->query_vars['s'];


Right here at line 61 right?

Re: S2Member and Wordpress Live Search

PostPosted: April 13th, 2011, 10:15 pm
by csixty4
Vitor,

Could you try a different change? Line 61 again. Take Jason's suggestion out and try this:

Code: Select all
$posts = $wpQueryResults->query(array(
's' => $_GET['s'],
'showposts' => $maxResults,
'post_type' => 'any',
'post_status' => 'publish',
));


Then, about 25 lines below that, replace:

Code: Select all
foreach($wpQueryResults->posts as $result)


with:

Code: Select all
foreach($posts as $result)

Re: S2Member and Wordpress Live Search

PostPosted: April 13th, 2011, 11:08 pm
by vitorclaw
Hey Dave, first of all thank you so much for taking your time to help.

Well, I tried to change the code just like you said but the private post still appearing on the search, even when its not beign displayed at the latest posts section. I also tried to change the alternate view protection to all other options and the posts still appearing. Applying the s2member filter to the query doesn`t work either.

By the way I got a strange behaviour, i got this from firebug console

Code: Select all
{"searchTerms":"teste","results":[],"displayPostMeta":false}


No results, but I have a post named Teste, which appears when i`m logged as an admin

Re: S2Member and Wordpress Live Search

PostPosted: April 16th, 2011, 6:26 pm
by vitorclaw
Hi guys, I`m still trying to find a solution for this, but I got nothing so far, the private posts still showing up when I`m using the live search :(

Re: S2Member and Wordpress Live Search

PostPosted: April 18th, 2011, 10:35 pm
by Jason Caldwell
OK. This seems to be related to the is_admin() Conditional, whenever AJAX requests are processed through /admin-ajax.php. You see, s2Member does NOT Filter queries processed inside admin panels for obvious reasons. However, as we've seen here, exceptions do exist ( i.e. Ajax search plugins ).

I'm attaching a patched file that can be uploaded to an existing installation of s2Member v3.5.8. Unzip the attached file, and upload it. Please allow this revised file to overwrite your existing copy of /s2member/includes/classes/querys.inc.php.

For Daves reference, and/or anyone else writing Ajax search plugins that you'd like to make compatible with s2Member's Query Filters, here is the section of code that was modified:
Code: Select all
if (!is_admin () /* The additional Ajax checks below, allow search plugins like Daves Live Search to be Filtered. Even when `is_admin() = true`.
See: `http://wordpress.org/extend/plugins/daves-wordpress-live-search/`. Also see: `http://www.primothemes.com/forums/viewtopic.php?f=4&t=3087#p12786`. */
|| (is_admin () && defined ("DOING_AJAX") && DOING_AJAX && !empty ($_REQUEST["action"]) && (did_action ("wp_ajax_nopriv_" . $_REQUEST["action"]) || did_action ("wp_ajax_" . $_REQUEST["action"])) && $wp_query->is_search ()))
    { 
Ajax Developers: please make sure that your plugin is using the WP_Query class, and please make sure that your Ajax request follows the WordPress standard of using /admin-ajax.php. Just like Daves Live Search plugin.

querys.inc.php.zip
(2.68 KiB) Downloaded 32 times

Also, please make sure s2Member's Alternative View Protection is set to: Searches, Searches and Feeds, or Yes ( All ). Any of those options should do fine. In the case of Daves Live Search, also make sure that you've cleared your search result cache under the Advanced Tab of Daves Live Search plugin.

This issue should be resolved now.
Please write back to confirm, and then we'll have the changes included in the release of s2Member v3.6+.

100% Resolved ( awaiting confirmation )

Re: S2Member and Wordpress Live Search

PostPosted: April 18th, 2011, 11:55 pm
by vitorclaw
Hi Jason, I don`t even know how to thank you for that. Worked perfectly, you`re great!

Re: S2Member and Wordpress Live Search

PostPosted: April 19th, 2011, 12:01 am
by Jason Caldwell
You're very welcome. Thanks for reporting back!
100% Resolved ( will be included with s2Member v3.6+ )

Re: S2Member and Wordpress Live Search

PostPosted: April 22nd, 2011, 10:37 pm
by csixty4
Great detective work! I've always hated how anonymous users' queries have to go through admin-ajax.php, and this is a perfect example of why.

Re: S2Member and Wordpress Live Search

PostPosted: July 8th, 2011, 11:45 am
by Guster
Hi there, I have an unusual problem that I need help with.
I have all of my level 1 pages restricted. I can access them with my admin account. But when my members get the level 1 membership they click on a level 1 page and it takes them to the membership options page.
So… For a test I put all the level 1 pages in level 0 and saved changes. Logged back into the site as a member instead of the admin, and it did the same thing as before (click on a level 1 page and it takes them to the membership options page).
Can you think of any reason for this?

Re: S2Member and Wordpress Live Search

PostPosted: July 8th, 2011, 5:10 pm
by Jason Caldwell
Guster wrote:Hi there, I have an unusual problem that I need help with.
I have all of my level 1 pages restricted. I can access them with my admin account. But when my members get the level 1 membership they click on a level 1 page and it takes them to the membership options page.
So… For a test I put all the level 1 pages in level 0 and saved changes. Logged back into the site as a member instead of the admin, and it did the same thing as before (click on a level 1 page and it takes them to the membership options page).
Can you think of any reason for this?
This sounds like your s2Member Roles have gotten corrupted somehow. Have you installed/used any of the User Role editing plugins? If all else fails, I would try deactivating s2Member, and then reactivate it so that your Roles/Capabilities get reset to the proper configuration.

Re: S2Member and Wordpress Live Search

PostPosted: July 8th, 2011, 5:36 pm
by Guster
I figured it out. I forgot that I put in all the member page ID’s in the “Specific Post/Page Access Restrictions”. I took them out and now it works great. Thanks again

Re: S2Member and Wordpress Live Search

PostPosted: July 8th, 2011, 7:08 pm
by Jason Caldwell
Ah. Thanks for reporting back.
~ that is MUCH appreciated!

Re: S2Member and Wordpress Live Search

PostPosted: September 2nd, 2011, 4:35 pm
by presson
Guster wrote:I figured it out. I forgot that I put in all the member page ID’s in the “Specific Post/Page Access Restrictions”. I took them out and now it works great. Thanks again


I'm wondering if there is a way to automate insertion in to these page restriction lists based on certain behaviors, like comments with certain keywords or something to that affect. i have been storing my data so that I have access via ediscovery, but I am on hold until I know what my capabilities are with this organized data. Have you ever heard of StoredIQ? It is an information governance provided.

Re: S2Member and Wordpress Live Search

PostPosted: September 2nd, 2011, 10:53 pm
by Cristián Lávaque
s2Member doesn't come with that, but you can certainly code a customization that achieves it, if you wanted to. You'd have to monitor the comments and posts for those keywords and update the restriction based on that.

If you don't know enough PHP for this, you can get help from a freelance developer in websites like jobs.wordpress.net, eLance.com or oDesk.com.

I hope that helps. :)