Detach_s2member_query_filters not working

I’m not sure why the functions offered in the documents don’t work :

detach_s2member_query_filters and attach_s2member_query_filters

My goal is to detach all the filters, and then attach them back, but this doesn’t work as expected. are these functions still maintained ?

This issue seems present on both Pro and Normal, and I’ve checked the code and couldn’t find interference from Pro to Default on this one.

So, even if its not maybe “the best practice”, I’ll just try to supress_filters, but that’s wrong if you think about it.
Anyway, because this function has no topic on either github or here, I’ll just leave my conclusion, and hopefully, someone, one day, will offer an answer.

In the end, I was forced to do this, well, I have no clue who’s crazy enough to use this, I’m doing it in a plugin, because S2 doesn’t give me an alternative.

public function before_grid_posts_query() {
    global $wp_filter;

    if( !isset( $wp_filter['pre_get_posts'] ) )
      return;

    foreach( $wp_filter['pre_get_posts'] as $priority => $actions_map ) {
      foreach ( $actions_map as $action_index => $action_definition ) {
        if( strpos( $action_index, 's2member' ) === false )
          continue;

        if( !isset( $this->_pre_get_posts_removed_actions[ $priority ] ) )
          $this->_pre_get_posts_removed_actions[ $priority ] = [];

        $this->_pre_get_posts_removed_actions[ $priority ][$action_index] = $action_definition;

        remove_action( 'pre_get_posts', $action_index, $priority );
      }
    }
  }

  public function after_grid_posts_query() {
    foreach( $this->_pre_get_posts_removed_actions as $priority => $actions_map )
      foreach ( $actions_map as $action_index => $action_definition )
        add_action( 'pre_get_posts', ( isset( $action_definition['function'] ) ? $action_definition['function'] : $action_index ), $priority );

    $this->_pre_get_posts_removed_actions = [];
  }

If you know enough to know about these filters, then you also know enough to know that you can’t expect meaningful help by posting something like this.

Last time I used them (within the last year), they worked fine. What have you tried with these filters, and what is happening?

Then why is it called detach s2member query filters, when it reverts between 2 actions ? detach / attach I expect to remove / add everything by using this function, even if the filters are detached, some websites still hide the posts to people without the access, same thing if I attach ( but it was just an attempt to see if it would actually work ), this is the only solution that I’ve found on S2 Member to work as expected, because there’s no way to remove all your filters, not even supressing filters does the trick, because these actions are on pre_get_posts.

As I said, it worked for me.

I asked a simple question, and you have chosen not to answer it. Clearly, therefore, you aren’t really seeking help at all. So I’ll leave you to it.

I wish everybody would stop assuming that anyone who answers a question here works for WebSharks. The fact is that you are much more likely to get a reply from a member of the community who is answering these questions out of the goodness of their heart (with no compensation nor any expectation of any compensation). Yet, we get responses all the time about how “your” software doesn’t work the way the poster thinks it should.

Tim asked for a detailed explanation of what you were trying to do and you just railed at him. I hardly think he’ll be back at this point.

If you think there is a bug in the software the appropriate place to post that information is on GitHub. That said, your original post hardly qualifies as a bug report. You don’t explain what you are trying to accomplish, what you expected to happen, or what happened instead.

In the end i’ve found a solution that works for me, maybe my attitude wasn’t right, and I’m sorry for that.

I’ve left my solution here for anyone else who may have this issue, because it’s not present neither on github or here.

But the only reason I have this problem, is because of poorly named functions, I purchased the caching solution, before being renamed to Zen Cache, and then Comet Cache and I’ve had a really high respect for WP Sharks, and having this bad habits in the code, I recommend S2 Member for people who want a membership solution, and many even buy it.

The rename from Zen Cache, the official post / email / notification whatver, clearly said something like “We’re just a small development company”, and from people that pride with that, driven by Developers if you think about it, I expect code that does what it does, and this function clearly does not do what it says it does.

detach / attach, maybe i’m not even the only developer that had this issue and at least now there’s a post that offers some insight.

Again, I never intended to offend anyone personally, neither a community member or a WP Sharks representative, even if deep down I would really like to offend whoever named those functions to something they’re not.