Last Updated: 2026-05-27 | Applies to: IK v1.2+ | Role: Teacher, Campus Admin
Overview
The Frontend Attendance Manager allows teachers to mark student attendance from the frontend of the website without accessing the WordPress admin panel. This is ideal for teachers who should not have backend access.
Setting Up the Attendance Page
Step 1: Create a WordPress Page
Page Title: Mark AttendanceSlug: mark-attendanceContent: [ik_frontend_attendance]Template: Full-widthVisibility: Password Protected (optional) or Public
Step 2: Restrict Access (Recommended)
Add password protection or use a membership plugin to ensure only teachers can access:
Page Password: [Set a secure password shared with teachers]
Or use the ik_section taxonomy to filter by assigned sections.
What Teachers See
Filter Form
When a teacher visits the page, they see:
┌─────────────────────────────────────────────────────┐│ Mark Student Attendance │├─────────────────────────────────────────────────────┤│ Select Campus: [North Branch ▾] (Admin only) ││ Select Class: [Grade 10 ▾] *Required ││ Select Section:[A ▾] ││ Select Date: [2026-06-15] ││ ││ [Show Student List] │└─────────────────────────────────────────────────────┘
Campus Access Logic:
- Teachers: Automatically restricted to their assigned campus (from staff table
primary_campus_id) - Admins: Can switch between all campuses
- Campus Admins: See only their campus
Section Requirement:If sections exist in the system, a section MUST be selected before students appear. This prevents accidentally marking attendance for the wrong section.
Attendance Sheet
After selecting class, section, and date:
┌──────────────────────────────────────────────────────────────┐│ Attendance for Class: Grade 10 (A) on June 15, 2026 │├──────────────────────────────────────────────────────────────┤│ Student Name │ Roll # │ Status │├──────────────────┼────────┼─────────────────────────────────┤│ John Doe │ 1001 │ ● Present ○ Absent ◐ Late ○ Leave ││ │ │ Father: +92-300-1234567 ││ │ │ [Remarks: ________] (if late/leave)│├──────────────────┼────────┼─────────────────────────────────┤│ Jane Smith │ 1002 │ ● Present ○ Absent ◐ Late ○ Leave ││ │ │ Mother: +92-300-7654321 │├──────────────────┼────────┼─────────────────────────────────┤│ Bob Wilson │ 1003 │ ○ Present ● Absent ◐ Late ○ Leave││ │ │ Father: +92-300-1112233 │└──────────────────┴────────┴─────────────────────────────────┘[Save Student Attendance]
Key Features
1. Parent Contact Display
Each student row shows parent contact numbers:
Father's Contact: +92-300-1234567 | Mother's Contact: +92-300-7654321
This allows teachers to quickly contact parents of absent students without switching screens.
Data source: Student meta fields _ik_father_contact and _ik_mother_contact.
2. Dynamic Remarks Field
The remarks field appears ONLY when "Late" or "Leave" is selected:
Status: ◐ Late[Reason for late/leave: Traffic delay - 15 minutes late]Status: ○ Leave[Reason for late/leave: Doctor's appointment]
For "Present" or "Absent", the remarks field is hidden and cleared automatically.
JavaScript Behavior:
- Page load: Shows remarks if saved status is late/leave
- Status change: Toggles visibility instantly
- Save: Clears remarks for present/absent
3. Read-Only Mode
Once attendance is saved for a date, the form becomes read-only:
┌──────────────────────────────────────────────────────────────┐│ ⚠️ Attendance for this date has been saved and is now ││ read-only from the front end. It can be modified by an ││ administrator from the back end. │├──────────────────────────────────────────────────────────────┤│ Attendance submitted by Ms. Sarah Khan at 08:45 AM │└──────────────────────────────────────────────────────────────┘
This prevents:
- Accidental double-marking
- Teachers overwriting each other's work
- Confusion about who marked attendance
4. Submission Tracking
After saving, the form shows:
- Who marked attendance (teacher name)
- When it was marked (time stamp)
- Campus context (for audit trail)
Database Operations
Save Logic:
php
For each student:├── Check if attendance record exists for (student_id, date, class_id)│ ├── EXISTS → UPDATE status, remarks, marked_by, marked_at│ └── NEW → INSERT with all fields└── Clear remarks for present/absent status
Table: wp_institutionkit_attendance
| Column | Description |
|---|---|
attendance_id | Auto-increment |
student_id | Student post ID |
class_id | Class post ID |
attendance_date | Date of attendance |
status | present, absent, late, leave |
remarks | Reason for late/leave |
marked_by | Teacher user ID |
marked_at | Timestamp |
campus_id | Campus context |
Campus Restriction Logic
Teacher Campus Detection (Priority Order):
1. Check institutionkit_staff table for user_id → get primary_campus_id2. Fallback: Use IK_Campus_Manager::get_user_campuses()3. No campus found → Cannot mark attendance (error shown)
Class Access Validation:
Is class allowed for this teacher?├── Class has no campus (global class) → YES, allowed├── Teacher is admin viewing all campuses → YES, allowed├── Class campus matches teacher's campus → YES, allowed└── Otherwise → NO, permission denied
Security Features
| Feature | Implementation |
|---|---|
| Nonce Verification | wp_verify_nonce('ik_save_attendance_action', 'ik_attendance_nonce') |
| Capability Check | current_user_can('mark_attendance') |
| Campus Restriction | Teacher can only mark their assigned campus |
| Class Validation | Class must belong to teacher's campus |
| Input Sanitization | All inputs sanitized before database operations |
| SQL Injection Prevention | All queries use $wpdb->prepare() |
Troubleshooting
Problem: "No students found for the selected class and section"Solution:
- Verify class has students enrolled
- Check section filter matches student assignments
- Confirm campus assignment for class
Problem: "You do not have permission to view attendance for this class"Solution:
- Teacher must be assigned to the class's campus
- Check
institutionkit_stafftable for correctprimary_campus_id
Problem: "Please select a section to view students"Solution:
- Sections exist in the system (created in Classes Management)
- Students are assigned to sections
- Select the appropriate section from dropdown
Problem: "Attendance already saved" but need to editSolution:
- Frontend is read-only after saving
- Admin must edit from backend: Student Management → Attendance
- This is intentional to prevent conflicts

Comments are closed.