jwondrusch (@jwondrusch)

Forum Replies Created

Viewing 1 replies (of 1 total)

  • jwondrusch
    Participant

    @jwondrusch

    After much trial and error, I’ve come to a solution that retains permission control and shows the first post when using Wishlist Member with bbPress:

    
    // Create a new filtering function that will add our where clause to the query
    add_filter( 'posts_where', 'your_filter_where', 99 );
    function your_filter_where( $where ) {
    
    	global $post;
            
            // Limit to posts so it's not ruining permission queries all around the site.  You could also check user level if you need further specificity.
    	if( get_post_type( $post->ID ) == 'topic' ) {
    
                    // The Solution: Match based on post id AND parent id.  The admin query did this, the user query did not, so we do a simple search and replace to make it happen.
    		$search = $wpdb->prefix . 'posts.post_parent = ' . $post->ID;
    		$replace = '( ' . $wpdb->prefix . 'posts.post_parent = ' . $post->ID . ' OR ' . $wpdb->prefix.'posts.ID = ' . $post->ID . ' ) ';
    		
    		$where = str_replace( $search, $replace, $where);
    
    	}
    
    	return $where;
    }
    

    Due to the way that WLM obfuscates their code, it’s impossible to know exactly HOW they are re-constructing queries, but this is a quick starting point for anyone looking to solve the issue of WLM not showing bbPress’s first post in a topic to users.

    Hope it helps!

    Jonathan

Viewing 1 replies (of 1 total)