posts_results filter function memory errors

Sorry folks – for those curious, I had already solved this later on in my functions.php file and forgot to turn this filter off (silly). Here’s the better solution if anyone cares to comment or improve. Basically, I’m filtering out content based on user role (I have a custom user role as well) so that posts aren’t shown to users who aren’t allowed to see them. This has to include sidebar widget (post archive listings, for example) and all other place where you might see a post title or link:

/*-----------------------------------------------------------------------------------*/
/* Filter out users who shouldn't see content */
/*-----------------------------------------------------------------------------------*/
function filter_users($query){

    if ( !is_admin() ) {

            if( is_page() ) { return; }

            $user_id    = get_current_user_id();
            $user_info  = get_userdata($user_id);
            $user_role  = $user_info->roles[0];
            $user_role  = ( $user_role == 'subscriber' || $user_role == 'author' || $user_role == 'contributor' || $user_role == 'editor' )  ? 'member' : $user_role;

            if ( $user_role == 'member' ) {

                //wordpress needs a value to compare or it won't work
                $query->set('meta_query', array(
                                            array(
                                                'meta_key'=>'who_can_view',
                                                'meta_value'=>'foobar',
                                                'compare' => 'NOT EXISTS',
                                            )   
                                          )
                            );

                add_filter( 'posts_join' , 'custom_posts_join' );
                add_filter( 'posts_where','custom_where' );

            }

    }

}
add_filter('pre_get_posts','filter_users');

function custom_posts_join($join){

    global $wpdb;

    $join .= " LEFT JOIN $wpdb->postmeta as meta_1 ON $wpdb->posts.ID = meta_1.post_id";

    return $join;
}

//Needed because WordPress craps the bed setting meta_query objects in pre_get_posts
function custom_where( $where="" ){

    global $wpdb;

    $where .= " AND ( meta_1.meta_key = 'who_can_view' AND meta_1.meta_value="member" )";

    remove_filter( 'posts_where', 'custom_where' );

    return $where;

} // custom_where

Cheers.