function prepare_items() { /* set up the columns */ $columns = $this->get_columns(); $hidden = array(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array($columns, $hidden, $sortable); /* set paging parameters */ $per_page = ltp_options::get_admin_per_page('ltp_student_users_pp'); $current_page = $this->get_pagenum(); $offset = ($current_page - 1) * $per_page; /* set ordering parameters */ $poss_orderby = array('first_name', 'last_name', 'user_login', 'user_email'); $orderby = isset($_REQUEST["orderby"]) && in_array($_REQUEST["orderby"], $poss_orderby) ? $_REQUEST["orderby"] : 'last_name'; $order = isset($_REQUEST["order"]) && in_array(strtoupper($_REQUEST["order"]), array('ASC', 'DESC')) ? strtoupper($_REQUEST["order"]) : 'ASC'; $searchterm = isset($_REQUEST["s"]) && trim($_REQUEST["s"]) !== '' ? trim($_REQUEST["s"]) : ''; /* build arguments to user query */ $args = array('role' => 'student', 'number' => $per_page, 'offset' => $offset, 'fields' => 'all_with_meta', 'count_total' => true); if ($searchterm !== '') { $args['meta_query'] = array('relation' => 'OR', array('key' => 'first_name', 'value' => $searchterm, 'compare' => 'LIKE'), array('key' => 'last_name', 'value' => $searchterm, 'compare' => 'LIKE')); } if ($orderby) { switch ($orderby) { case 'first_name': case 'last_name': $args['orderby'] = 'meta_value'; $args['meta_key'] = $orderby; break; default: $args['orderby'] = $orderby; } $args['order'] = $order; } /* query users */ $user_query = new WP_User_Query($args); /* get total users */ $total_items = $user_query->get_total(); /* get results */ $wpp_users = $user_query->get_results(); /* get additional data */ /* get people pages */ $people_pages = get_posts(array('post_type' => 'people', 'numberposts' => -1, 'nopaging' => true, 'post_status' => 'any')); /* map people page IDs to usernames */ $pages_map = array(); foreach ($people_pages as $pp) { $wp_username = get_post_meta($pp->ID, 'wp_username', true); if ($wp_username) { $pages_map[$wp_username] = $pp; } } /* build items for table */ $this->items = array(); if (!empty($user_query->results)) { foreach ($user_query->results as $user) { $userdata = ltp_template::get_user_data($user); $student_user = array(); $student_user["ID"] = $user->ID; $student_user["first_name"] = $user->first_name; $student_user["last_name"] = $user->last_name; $student_user["user_login"] = $user->user_login; $student_user["user_email"] = $user->user_email; $student_user["showcase_count"] = 0; $student_user["downloads_count"] = 0; $student_user["cv_uploaded"] = false; $student_user["profile_url"] = ''; $student_user["profile_views"] = 0; /* get data related to profile publishing status */ if (!isset($pages_map[$user->user_login])) { $student_user["profile_status"] = "Not started"; } else { /* find out how much has been done on the profile */ for ($i = 1; $i < 4; $i++) { if (trim($userdata["showcase" . $i . "_title"]) !== '' || trim($userdata["showcase" . $i . "_text"]) !== '' || trim($userdata["showcase" . $i . "_image"]) !== '' || trim($userdata["showcase" . $i . "_file"]) !== '' || trim($userdata["showcase" . $i . "_video"]) !== '') { $student_user["showcase_count"]++; } } if (!empty($userdata["cv"])) { $student_user["cv_uploaded"] = true; $student_user["downloads_count"] = ltp_data::get_downloads($pages_map[$user->user_login]->ID); } /* set status, view count and URL */ if ($pages_map[$user->user_login]->post_status == "publish") { $student_user["profile_status"] = "Published"; $student_user["profile_url"] = get_permalink($pages_map[$user->user_login]->ID); } else { $student_user["profile_status"] = "Draft"; } $student_user["profile_views"] = ltp_data::get_views($pages_map[$user->user_login]->ID); } //print('<pre>' . print_r($student_user, true) . '</pre>'); array_push($this->items, $student_user); } } }
} } // apply filters on $students to see which pages are to be displayed //$to_display = apply_filters( 'ltp_results', $students ); $count = 0; // loop through people pages displaying users foreach ($people_pages as $post) { $username = get_post_meta($post->ID, 'wp_username', true); if (in_array($username, array_keys($students))) { // display user data if (trim($students[$username]["firstname"]) !== '' && trim($students[$username]["surname"]) !== '') { $latest = false; foreach ($profiles_added as $newprofile) { if ($post->ID == $newprofile->ID) { $latest = true; break; } } print ltp_template::get_vcard($students[$username], $post->ID, $latest); $count++; } } } print '</div>'; // no profiles messages print '<p class="message" id="no-saved-profiles">No profiles have been saved</p>'; print '<p class="message" id="no-filtered-profiles">No profiles match your search criteria</p>'; } else { print '<p>No profiles have been added to the system yet - please try again later…</p>'; } get_footer();
$user = get_user_by('login', $username); } $options = ltp_options::get_options(); /* start profile output */ print '<div class="ltp-profile-viewer">'; // se if a CV has been uploaded $cv_URL = ''; $cv_ID = get_user_meta($user->ID, 'cv', true); if ($cv_ID !== '') { $cv_URL = wp_get_attachment_url($cv_ID); } // start toolbar output print '<div class="section sticky toolbar">'; if (ltp_is_wpp()) { // WPP users toolbar print ltp_template::wpp_profile_toolbar($current_user->ID, $post->ID, $cv_URL); } elseif ($current_user->ID == $user->ID) { // student toolbar printf('<div class="status">Profile views: %d | Profile saves: %d | CV downloads: %d</div>', ltp_data::get_views($post->ID), ltp_data::get_saves($post->ID), ltp_data::get_downloads($post->ID)); printf('<form action="%s" method="post">', get_permalink($options["builder_page_id"])); print '<button name="return" class="ppt-button ppt-return-button">Return to profile builder</button>'; if ($post->post_status !== 'publish') { print '<button name="publish" class="ppt-button ppt-publish-button">Publish</button>'; } else { print '<button name="unpublish" class="ppt-button ppt-unpublish-button">Un-publish</button>'; } print '<p><em>This is how recruiters will see your profile</em></p>'; print '</form>'; } print '</div>'; print '<div class="ltp-profile-wrap"><div class="vcard">';
if (isset($options["debug_ssl"]) && intval($options["debug_ssl"]) > 0) { wp_redirect(str_replace('http:', 'https:', get_permalink($user_page->ID))); } else { wp_redirect(get_permalink($user_page->ID)); } } } get_header(); if (have_posts()) { while (have_posts()) { the_post(); if (class_exists("PeoplePostType")) { printf('<form action="%s" method="post" class="ltp-profile-builder"><h2>%s</h2>', get_permalink($post->ID), get_the_title()); echo PeoplePostType::get_profile_field_control(array('field_name' => 'nonce')); //printf( '<p class="compulsory">Compulsory field</p>'); echo ltp_template::profile_toolbar($has_page, $is_published); // student photo print '<div class="section top"><h3>1. Upload Photo</h3>'; echo PeoplePostType::get_profile_field_control(array('field_name' => 'photo')); print '</div>'; // student basic information print '<div class="section"><h3>2. Basic Information</h3>'; echo PeoplePostType::get_profile_field_control(array('field_name' => 'firstname')); echo PeoplePostType::get_profile_field_control(array('field_name' => 'surname')); echo '<br style="clear:both">'; echo PeoplePostType::get_profile_field_control(array('field_name' => 'gender')); echo PeoplePostType::get_profile_field_control(array('field_name' => 'experience')); echo PeoplePostType::get_profile_field_control(array('field_name' => 'region')); print '</div>'; print '<div class="section"><h3>3. Regions I would like to work in</h3><div class="checkbox-list">'; echo PeoplePostType::get_profile_field_control(array('field_name' => 'desired_region'));