function handle_members_updates()
 {
     global $action, $page;
     wp_reset_vars(array('action', 'page'));
     if (isset($_GET['doaction']) || isset($_GET['doaction2'])) {
         if (addslashes($_GET['action']) == 'toggle' || addslashes($_GET['action2']) == 'toggle') {
             $action = 'bulk-toggle';
         }
     }
     switch (addslashes($action)) {
         case 'removeheader':
             $this->dismiss_user_help($page);
             wp_safe_redirect(remove_query_arg('action'));
             break;
         case 'toggle':
             if (isset($_GET['member_id'])) {
                 $user_id = (int) $_GET['member_id'];
                 check_admin_referer('toggle-member_' . $user_id);
                 $member = new M_Membership($user_id);
                 if ($member->toggle_activation()) {
                     wp_safe_redirect(add_query_arg('msg', 7, wp_get_referer()));
                 } else {
                     wp_safe_redirect(add_query_arg('msg', 8, wp_get_referer()));
                 }
             }
             break;
         case 'bulk-toggle':
             check_admin_referer('bulk-members');
             foreach ($_GET['users'] as $value) {
                 if (is_numeric($value)) {
                     $user_id = (int) $value;
                     $member = new M_Membership($user_id);
                     $member->toggle_activation();
                 }
             }
             wp_safe_redirect(add_query_arg('msg', 7, wp_get_referer()));
             break;
         case 'bulkaddlevel-level-complete':
         case 'addlevel-level-complete':
             check_admin_referer($action);
             $members_id = $_POST['member_id'];
             $members = explode(',', $members_id);
             if ($members) {
                 foreach ($members as $member_id) {
                     $member = new M_Membership($member_id);
                     $tolevel_id = (int) $_POST['tolevel_id'];
                     if ($tolevel_id) {
                         $member->add_level($tolevel_id);
                     }
                 }
             }
             $this->update_levelcounts();
             wp_safe_redirect(add_query_arg('msg', 3, wp_get_original_referer()));
             break;
         case 'bulkdroplevel-level-complete':
         case 'droplevel-level-complete':
             check_admin_referer($action);
             $members_id = $_POST['member_id'];
             $members = explode(',', $members_id);
             if ($members) {
                 foreach ($members as $member_id) {
                     $member = new M_Membership($member_id);
                     $fromlevel_id = (int) $_POST['fromlevel_id'];
                     if ($fromlevel_id) {
                         $member->drop_level($fromlevel_id);
                     }
                 }
             }
             $this->update_levelcounts();
             wp_safe_redirect(add_query_arg('msg', 3, wp_get_original_referer()));
             break;
         case 'bulkmovelevel-level-complete':
         case 'movelevel-level-complete':
             check_admin_referer($action);
             $members_id = $_POST['member_id'];
             $members = explode(',', $members_id);
             if ($members) {
                 foreach ($members as $member_id) {
                     $member = new M_Membership($member_id);
                     $fromlevel_id = (int) $_POST['fromlevel_id'];
                     $tolevel_id = (int) $_POST['tolevel_id'];
                     if ($fromlevel_id && $tolevel_id) {
                         $member->move_level($fromlevel_id, $tolevel_id);
                     }
                 }
             }
             $this->update_levelcounts();
             wp_safe_redirect(add_query_arg('msg', 3, wp_get_original_referer()));
             break;
         case 'bulkaddsub-sub-complete':
         case 'addsub-sub-complete':
             check_admin_referer($action);
             $members_id = $_POST['member_id'];
             $members = explode(',', $members_id);
             if ($members) {
                 foreach ($members as $member_id) {
                     $member = new M_Membership($member_id);
                     $tosub_id = $_POST['tosub_id'];
                     if ($tosub_id) {
                         $subs = explode('-', $tosub_id);
                         if (count($subs) == 3) {
                             $member->add_subscription($subs[0], $subs[1], $subs[2]);
                         }
                     }
                 }
             }
             $this->update_levelcounts();
             $this->update_subcounts();
             wp_safe_redirect(add_query_arg('msg', 3, wp_get_original_referer()));
             break;
         case 'bulkdropsub-sub-complete':
         case 'dropsub-sub-complete':
             check_admin_referer($action);
             $members_id = $_POST['member_id'];
             $members = explode(',', $members_id);
             if ($members) {
                 foreach ($members as $member_id) {
                     $member = new M_Membership($member_id);
                     $fromsub_id = (int) $_POST['fromsub_id'];
                     if ($fromsub_id) {
                         $member->drop_subscription($fromsub_id);
                     }
                 }
             }
             $this->update_levelcounts();
             $this->update_subcounts();
             wp_safe_redirect(add_query_arg('msg', 3, wp_get_original_referer()));
             break;
         case 'bulkmovesub-sub-complete':
         case 'movesub-sub-complete':
             check_admin_referer($action);
             $members_id = $_POST['member_id'];
             $members = explode(',', $members_id);
             if ($members) {
                 foreach ($members as $member_id) {
                     $member = new M_Membership($member_id);
                     $fromsub_id = (int) $_POST['fromsub_id'];
                     $tosub_id = $_POST['tosub_id'];
                     if ($fromsub_id && $tosub_id) {
                         $subs = explode('-', $tosub_id);
                         if (count($subs) == 3) {
                             $member->move_subscription($fromsub_id, $subs[0], $subs[1], $subs[2]);
                         }
                     }
                 }
             }
             $this->update_levelcounts();
             $this->update_subcounts();
             wp_safe_redirect(add_query_arg('msg', 3, wp_get_original_referer()));
             break;
         case 'bulkmovegateway-gateway-complete':
         case 'movegateway-gateway-complete':
             check_admin_referer($action);
             $members_id = $_POST['member_id'];
             $members = explode(',', $members_id);
             if ($members) {
                 foreach ($members as $member_id) {
                     $member = new M_Membership($member_id);
                     $fromgateway = $_POST['fromgateway'];
                     $togateway = $_POST['togateway'];
                     if (!empty($fromgateway) && !empty($togateway)) {
                         $relationships = $member->get_relationships();
                         foreach ($relationships as $rel) {
                             if ($rel->usinggateway == $fromgateway) {
                                 $member->update_relationship_gateway($rel->rel_id, $fromgateway, $togateway);
                             }
                         }
                     }
                 }
             }
             wp_safe_redirect(add_query_arg('msg', 3, wp_get_original_referer()));
             break;
     }
 }