missing_leg_session.diff

missing_leg_session.diff
diff --git a/docroot/sites/all/modules/custom/cga_legislators/cga_legislators.module b/docroot/sites/all/modules/custom/cga_legislators/cga_legislators.module
index 394d474..503a3e9 100644
--- a/docroot/sites/all/modules/custom/cga_legislators/cga_legislators.module
+++ b/docroot/sites/all/modules/custom/cga_legislators/cga_legislators.module
@@ -41,6 +41,7 @@ function cga_legislators_block_view($delta = '') {
       $committees = array();
       $committees['role'] = array();
       $committees['no_role'] = array();
+      $current_sess = cga_entity_queries_get_current_or_most_recent_session();
       foreach ($relations as $relation) {
         $wrapper = entity_metadata_wrapper('relation', $relation);
         $endpoints = $wrapper->endpoints->value();
@@ -53,6 +54,11 @@ function cga_legislators_block_view($delta = '') {
         foreach ($endpoints as $node) {
           if ($node->type->value() != 'legislator') {
             $w = entity_metadata_wrapper('node', $node);
+            // Check if committee is in the current session, if not, do not show on the legislator page.
+            $committee_sess = $w->field_session->value();
+            if($current_sess->tid != $committee_sess->tid) {
+              continue;
+            }
             // Add to committees array only if this committee is toggled for display
             if($w->field_display_on_member_page->value() == 1) {
               if (!empty($role)) {