function render_privacy_page() { require_once WPPR_PLUGIN_DIR . '/models/members-model.php'; $model = new Members_Model(); $attributes = array('errors' => array(), 'success' => false); if (is_user_logged_in()) { // get current user id $this->user_id = get_current_user_id(); if (isset($_POST['submit']) && $_POST['submit'] == 'save') { if (isset($_POST['privacy'])) { $this->update_privacy($_POST['privacy']); } } // get current user's metada $meta = get_user_meta($this->user_id); $userdata = get_userdata($this->user_id); $this->user_url = $userdata->user_url; $this->display_name = $userdata->display_name; $this->ref_sports = $model->get_other_sports(); //get only meta keys with value $meta = array_filter(array_map(function ($a) { return $a[0]; }, $meta)); $member_meta = $model->get_member_meta(); foreach ($member_meta as $key) { if (isset($meta[$key])) { $this->{$key} = $meta[$key]; if ($key == 'interests') { $this->interests = unserialize($this->interests); } if ($key == 'gender') { $this->gender == 1 ? $this->gender = 'Male' : ($this->gender = 'Female'); } if ($key == 'birth_month') { $this->birth_month = date('F', mktime(0, 0, 0, $this->birth_month, $this->birth_day)); } $this->age = PR_Membership::compute_age($this->birth_month, $this->birth_day, $this->birth_year); } } /* Privacy Check */ $meta_keys = $model->get_privacy_meta(); foreach ($meta_keys as $key) { if (isset($meta[$key])) { $this->{$key} = $meta[$key]; } } } require_once dirname(__DIR__) . '/views/privacy.php'; }
function render_edit_profile() { require_once WPPR_PLUGIN_DIR . '/models/members-model.php'; $model = new Members_Model(); if (is_user_logged_in()) { $this->user_id = get_current_user_id(); if (isset($_POST['profile'])) { $result = $this->update($_POST['profile']); } $meta = get_user_meta($this->user_id); //Filter out empty meta data $meta = array_filter(array_map(function ($a) { return $a[0]; }, $meta)); if (isset($meta['first_name'])) { $this->first_name = $meta['first_name']; } if (isset($meta['last_name'])) { $this->last_name = $meta['last_name']; } if (isset($meta['description'])) { $this->description = $meta['description']; } $userdata = get_userdata($this->user_id); $this->user_url = $userdata->user_url; $this->display_name = $userdata->display_name; $this->ref_sports = $model->get_other_sports(); if (isset($meta['other_sports'])) { $this->other_sports = $meta['other_sports']; $this->other_sports = unserialize($this->other_sports); } $this->ref_interests = $model->get_interest_lists(); if (isset($meta['interests'])) { $this->interests = $meta['interests']; $this->interests = unserialize($this->interests); } if (isset($meta['location'])) { $this->location = $meta['location']; } if (isset($meta['gender'])) { $this->gender = $meta['gender']; } if (isset($meta['birth_day'])) { $this->birth_day = $meta['birth_day']; } if (isset($meta['birth_month'])) { $this->birth_month = $meta['birth_month']; } $this->months = array('1' => 'January', '2' => 'February', '3' => 'March', '4' => 'April', '5' => 'May', '6' => 'June', '7' => 'July', '8' => 'August', '9' => 'September', '10' => 'October', '11' => 'November', '12' => 'December'); if (isset($meta['birth_year'])) { $this->birth_year = $meta['birth_year']; } if (isset($meta['height'])) { $this->height = $meta['height']; } if (isset($meta['weight'])) { $this->weight = $meta['weight']; } if (isset($meta['year_started_running'])) { $this->year_started_running = $meta['year_started_running']; } if (isset($meta['facebook'])) { $this->facebook = $meta['facebook']; } if (isset($meta['twitter'])) { $this->twitter = $meta['twitter']; } if (isset($meta['instagram'])) { $this->instagram = $meta['instagram']; } require_once dirname(__DIR__) . '/views/edit-profile.php'; } else { redirect_to_home(); } }