Frontend Attendance Marking for Teachers

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

ColumnDescription
attendance_idAuto-increment
student_idStudent post ID
class_idClass post ID
attendance_dateDate of attendance
statuspresent, absent, late, leave
remarksReason for late/leave
marked_byTeacher user ID
marked_atTimestamp
campus_idCampus 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

FeatureImplementation
Nonce Verificationwp_verify_nonce('ik_save_attendance_action', 'ik_attendance_nonce')
Capability Checkcurrent_user_can('mark_attendance')
Campus RestrictionTeacher can only mark their assigned campus
Class ValidationClass must belong to teacher's campus
Input SanitizationAll inputs sanitized before database operations
SQL Injection PreventionAll queries use $wpdb->prepare()

Troubleshooting

Problem: "No students found for the selected class and section"Solution:

  1. Verify class has students enrolled
  2. Check section filter matches student assignments
  3. Confirm campus assignment for class

Problem: "You do not have permission to view attendance for this class"Solution:

  1. Teacher must be assigned to the class's campus
  2. Check institutionkit_staff table for correct primary_campus_id

Problem: "Please select a section to view students"Solution:

  1. Sections exist in the system (created in Classes Management)
  2. Students are assigned to sections
  3. Select the appropriate section from dropdown

Problem: "Attendance already saved" but need to editSolution:

  1. Frontend is read-only after saving
  2. Admin must edit from backend: Student Management → Attendance
  3. This is intentional to prevent conflicts

Comments are closed.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
💬 Ask Me Anything!