function watupro_user_certificates() { global $wpdb, $user_ID; $certificate = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WATUPRO_CERTIFICATES . " WHERE ID=%d", $_GET['id'])); // check access $multiuser_access = 'all'; if (watupro_intel()) { $multiuser_access = WatuPROIMultiUser::check_access('certificates_access'); } if ($multiuser_access == 'own') { if ($certificate->editor_id != $user_ID) { wp_die(__('You can manage only your own certificates', 'watupro')); } } if (!empty($_GET['approve'])) { $wpdb->query($wpdb->prepare("UPDATE " . WATUPRO_USER_CERTIFICATES . " SET pending_approval = 0 WHERE ID=%d", $_GET['user_certificate_id'])); // send email to user? if ($certificate->approval_notify_user) { WatuPROCertificate::approval_notify($certificate, $_GET['user_certificate_id']); } watupro_redirect("admin.php?page=watupro_user_certificates&id=" . $_GET['id']); } if (!empty($_GET['delete'])) { $wpdb->query($wpdb->prepare("DELETE FROM " . WATUPRO_USER_CERTIFICATES . " WHERE ID=%d", $_GET['user_certificate_id'])); } // select users $users = $wpdb->get_results($wpdb->prepare("SELECT tUC.ID as user_certificate_id, tU.user_nicename as user_nicename, tU.user_email as user_email, \n\ttE.name as exam_name, tUC.pending_approval as pending_approval, tT.ID as taking_id, tT.date as taking_date, tT.result as taking_result,\n\ttE.ID as exam_id\n\tFROM " . WATUPRO_USER_CERTIFICATES . " tUC \n\tJOIN {$wpdb->users} tU ON tUC.user_id = tU.ID \n\tJOIN " . WATUPRO_TAKEN_EXAMS . " tT ON tT.user_id = tU.ID AND tT.ID = tUC.taking_id\n\tJOIN " . WATUPRO_EXAMS . " tE ON tE.ID = tT.exam_id AND tE.ID = tUC.exam_id\n\tWHERE tUC.certificate_id=%d\n\tORDER BY tT.ID DESC", $certificate->ID)); $dateformat = get_option('date_format'); $is_admin = true; wp_enqueue_script('thickbox', null, array('jquery')); wp_enqueue_style('thickbox.css', '/' . WPINC . '/js/thickbox/thickbox.css', null, '1.0'); if (@file_exists(get_stylesheet_directory() . '/watupro/users-earned-certificate.html.php')) { require get_stylesheet_directory() . '/watupro/users-earned-certificate.html.php'; } else { require WATUPRO_PATH . "/views/users-earned-certificate.html.php"; } }