public function render()
 {
     require_once WPPR_PLUGIN_DIR . '/models/members-model.php';
     $model = new Members_Model();
     if (is_user_logged_in()) {
         $model->user_id = get_current_user_id();
         $this->connections = $model->get_all_connections();
         require_once dirname(__DIR__) . '/views/connections.php';
     } else {
         //redirect to login page
         PR_Membership::pr_redirect(home_url());
     }
 }
 private function update_privacy($post)
 {
     require_once WPPR_PLUGIN_DIR . '/models/members-model.php';
     $model = new Members_Model();
     foreach ($post as $key => $val) {
         if (isset($post[$key])) {
             if (metadata_exists('user', $this->user_id, $key)) {
                 $result = update_user_meta($this->user_id, $key, $val, get_user_meta($this->user_id, $key, true));
             } else {
                 $result = add_user_meta($this->user_id, $key, $val, true);
             }
         }
         $updated_meta[] = $key;
     }
     $meta = $model->get_privacy_meta();
     foreach ($meta as $key) {
         if (!in_array($key, $updated_meta)) {
             $result = update_user_meta($this->user_id, $key, 0, get_user_meta($this->user_id, $key, true));
         }
     }
     if (!is_wp_error($result)) {
         return true;
     } else {
         return false;
     }
 }
 private function update($post)
 {
     require_once WPPR_PLUGIN_DIR . '/models/members-model.php';
     $model = new Members_Model();
     if (isset($post)) {
         $valid = $this->validate_profile($_POST['profile'], $this->user_id);
         if (is_wp_error($valid)) {
             $errors[] = $valid->get_error_message();
             $result['errors'] = $errors;
         } else {
             $model->user_id = $this->user_id;
             $model->profile = $post;
             $success = $model->update_profile();
             if (!is_wp_error($success)) {
                 $result['success'] = 'You successfully updated your profile.';
             } else {
                 $result['errors'] = $success->get_error_message();
             }
         }
         wp_reset_postdata();
         return $result;
     }
 }