Skip to content

Hooks & filters

Sikshya is built around the standard WordPress action / filter system. Drop these into your child theme's functions.php or a small custom plugin.

Plugin lifecycle

HookTypeArgsWhen
sikshya_initactionSikshya boots (Plugin.php:295+)
sikshya_loadedactionAll free + Pro hooks registered
sikshya_admin_initactionAdmin context ready
sikshya_activatedactionFirst activation (Installer.php:62)
sikshya_deactivatedactionOn deactivation (Deactivator.php:33)
sikshya_register_addon_rest_routesactionWP_REST_Server $serverREST init for add-on routes (Api.php:612)

Enrollment, progress, and learner journey

HookTypeArgsNotes
sikshya_user_enrolledaction$user_id, $course_id, $contextFires after enrollment row written
sikshya_user_unenrolledaction$user_id, $course_id, $contextManual or self-unenroll
sikshya_lesson_completedaction$user_id, $lesson_id, $course_idAfter progress row updated
sikshya_quiz_completedaction$user_id, $quiz_id, $score, $passedAfter attempt finalized
sikshya_assignment_submittedaction$user_id, $assignment_id, $submission_idAfter upload
sikshya_assignment_completedaction$user_id, $assignment_id, $course_idAfter grading marks assignment complete
sikshya_course_completedaction$user_id, $course_idAll requirements met
sikshya_can_complete_lessonfilterbool $can, $user_id, $lesson_idVeto auto-complete
sikshya_enroll_free_redirect_urlfilterstring $url, $user_id, $course_idRedirect target after free self-enroll

Commerce, checkout, payments

HookTypeArgsNotes
sikshya_order_fulfilledaction$order_id, $contextAfter fulfillment service runs
sikshya_invoice_issuedaction$invoice_id, $order_idAfter invoice service
sikshya_checkout_start_gateway_sessionfilterarray $session, $order, $gateway_idWrap third-party gateway session start
sikshya_checkout_confirm_gatewayaction$order_id, $gateway_id, array $payloadConfirm an order from a gateway webhook
sikshya_coupon_discount_amountfilter$amount, $coupon, $cart, $line, $contextModify coupon discount math
sikshya_payment_gateways_registryfilterarray $registryAdd / remove gateways
sikshya_webhook_stripe_subscription_eventactionarray $event, $order_idStripe customer.subscription.*
sikshya_webhook_stripe_invoice_paymentactionarray $event, $order_idStripe invoice.*
sikshya_webhook_paypal_subscription_eventactionarray $event, $order_idPayPal subscription events

Certificates

HookTypeArgsNotes
sikshya_certificate_issuedaction$certificate_id, $user_id, $course_idAfter certificate row + email
sikshya_certificate_row_createdaction$certificate_id, $user_id, $course_idFires after the DB row is created

Settings, pages, navigation

HookTypeArgsNotes
sikshya_settings_tabsfilterarray $tabsAdd a settings tab
sikshya_settings_tab_{$tab}filterarray $sectionsAdd sections to a specific tab
sikshya_addons_registryfilterarray $registryRegister a custom add-on
sikshya_account_dashboard_afteraction$userInject UI after the account dashboard
sikshya_learn_template_datafilterarray $data, $contextModify learn-page payload (legacy hook + new model)
sikshya_learn_sidebar_footeraction$contextInject UI in the learn sidebar footer

Authentication & instructor lifecycle

HookTypeArgsNotes
sikshya_send_new_user_notificationsfilterbool $send, $user_idDisable core new-user emails
sikshya_instructor_application_submittedaction$user_id, array $payloadPending instructor application recorded

Licensing / Pro feature gating (free side)

HookTypeArgsNotes
sikshya_commercial_is_activefilterbool $activePro flips this true via LicenseBootstrap
sikshya_commercial_site_tierfilterstring $tierfree / starter / pro / scale
sikshya_commercial_feature_statesfilterarray $statesOverride per-feature plan availability

Reviews, discussions, Q&A (free + Pro)

HookTypeArgsNotes
sikshya_feature_reviews_availablefilterbool $onFlip review UI
sikshya_feature_discussions_availablefilterbool $onFlip in-course discussions
sikshya_feature_qa_availablefilterbool $onFlip Q&A panel

Pro add-on examples (already defined)

These ship with Pro add-ons but are listed here for discoverability:

HookWhen
sikshya_bundle_pricing_resolvedCourse bundle price resolved at checkout
sikshya_course_bundles_after_createNew bundle created
sikshya_course_bundles_allow_trashVeto bundle deletion
sikshya_coupon_blocked_messageCoupon UX blocked-coupon message
sikshya_coupons_advanced_blocked_messageAdvanced coupon blocked message
sikshya_coupons_advanced_normalize_save_metaNormalize advanced coupon meta on save
sikshya_activity_log_action_labelRe-label an activity action
sikshya_activity_log_allow_insertVeto an activity log insert
sikshya_activity_log_scope_course_idsLimit activity log scope
sikshya_activity_log_show_learn_sidebarShow / hide the activity log on the learn sidebar
sikshya_activity_log_recordedAfter a row is stored

Cron events

Free:

Cron hookFrequencyPurpose
sikshya_usage_tracking_eventweeklyOptional usage insights (opt-in)
sikshya_usage_tracking_immediateonceInitial usage ping
sikshya_run_legacy_migration_batchsingleConditional migration runner

Pro (samples — only scheduled when add-on is on):

Cron hookPurpose
sikshya_pro_daily_license_checkLicense heartbeat
sikshya_pro_drip_cronContent drip unlocks
sikshya_activity_log_retention_cronPurge old activity log rows
sikshya_pro_enterprise_reports_tickEnterprise report scheduler
sikshya_pro_enterprise_reports_runRun a scheduled report
sikshya_pro_enterprise_report_cronBackwards-compat scheduled hook
sikshya_marketplace_release_due_earningsRelease marketplace earnings
sikshya_pro_scorm_h5p_retention_sweepClean up SCORM artifacts
sikshya_email_marketing_run_jobRun an email-marketing sync
sikshya_webhooks_outbound_deliverDeliver outbound webhooks

Patterns

Send a Slack message on every enrollment

php
add_action('sikshya_user_enrolled', function ($user_id, $course_id, $context) {
    $user = get_userdata($user_id);
    $course = get_post($course_id);
    wp_remote_post('https://hooks.slack.com/services/T.../B.../X...', [
        'body' => wp_json_encode([
            'text' => sprintf(
                ':books: %s enrolled in *%s*',
                $user->display_name,
                get_the_title($course)
            ),
        ]),
        'headers' => ['Content-Type' => 'application/json'],
    ]);
}, 10, 3);

Issue a shop coupon when a learner completes a course

php
add_action('sikshya_course_completed', function ($user_id, $course_id) {
    $code = 'COURSE_' . $course_id . '_' . $user_id;
    // Create a 10% off coupon via your shop (Woo example)
    if (!function_exists('wc_create_coupon')) return;
    wc_create_coupon([
        'code' => $code,
        'discount_type' => 'percent',
        'amount' => 10,
        'usage_limit' => 1,
        'email_restrictions' => [get_userdata($user_id)->user_email],
    ]);
}, 10, 2);

Disable a Pro add-on for a specific user / role

php
add_filter('sikshya_commercial_feature_states', function ($states) {
    if (current_user_can('subscriber')) {
        $states['gradebook'] = false;
    }
    return $states;
});

Inject extra data into the certificate email

php
add_filter('sikshya_email_body', function ($body, $template_id, $context) {
    if ($template_id === 'learner_certificate_issued') {
        $body .= "\n\nDownload PDF: " . esc_url($context['certificate_url']);
    }
    return $body;
}, 10, 3);

Restrict who can use the public REST API (Scale add-on)

php
add_filter('sikshya_public_api_allowed_user_ids', function ($ids) {
    return [1, 2]; // only super-admins issue / use keys
});
  • REST API — every route on /wp-json/sikshya/v1/.
  • Pro add-ons — features behind feature flags.
  • Architecture — layered design (controller → service → repo → model → template).