Namaste! LMS Developers Guide

Extending and Customizing Namaste! LMS With Your Own Modules

Built To Extend

Namaste! LMS is built with the idea to be easily extendible and customizable. Besides installing any of the existing modules, you can write your own using the Namaste! LMS hooks. On this page you will find the hooks documentation.

Filters and Action Hooks

The documentation and the available hooks are constantly updated. If you need to request a filter or an action hook, feel free to contact us.

Please also feel free to explore the plugin source code for hooks that are not yet documented.

Namaste! API uses WordPress do_action calls to create custom actions. This means that in order to add custom functionality you need to use add_action() to call your custom functions. Any custom parameters passed to do_action will be shown below.
There are also some filters that allow you to modify variables and content output on the front-end.

do_action('namaste_homework_form', $homework); is called at the bottom of the add/edit assignment form. The $homework parameter contains the homework object from the database. When adding new homework, this parameter is empty. You need to echo the HTML code that you want to add to the form. The action should be used with namaste_add_homework and namaste_save_homework actions explained below.

do_action('namaste_add_homework', $id); is called after an assignment/homework is inserted in the database. Passes the ID of the inserted record. You can process your custom fields from $_POST to update the record. You will have to run another DB query for this. There is no reasonable way to avoid it.

do_action('namaste_save_homework', $id); - same as namaste_add_homework action above but is called when existing homework is edited.

do_action('namaste_submitted_solution', $user_id, $homework_id); is called when solution to homework has been submitted. Passes the user ID of submitter and $homework_id of the assignment. If you want to get the ID of the submitted solution you'd need to select the latest record for that user ID and assignment ID.

do_action('namaste_change_solution_status', $student_id, $solution_id, $status); - when teacher approves or rejects student's solution to assignment. Passes the student ID, their solution ID and the status (string) - 'approved', 'rejected', or 'pending'.

do_action('namaste_added_homework_note', $student_id, $homework_id, $note); - called when teacher adds a note to a homework. Passes ID of the student who receives the note, the ID of the related assignment and the actual note contents.

do_action('namaste_enrolled_course', $student_id, $course_id, $status); - when student enrolls in a course. Passes the student ID, course ID and status - 'enrolled' or 'pending'.

do_action('namaste_admin_enrolled_course', $student_id, $course_id, $status); - same as above but called when admin manually enrolls student to a course.

do_action('namaste_completed_course', $student_id, $course_id); is called when student comples a course. Passes the ID of student and ID of the completed course.

do_action('namaste_course_progress_view', $student_id, $course_id); is called at the end of the "Course progress". It allows you to add any custom information about this student/course.

do_action('namaste_enrollment_approved', $student_id, $course_id); - when teacher approves student's enrollment in a course. Passes student ID and course ID.

do_action('namaste_enrollment_rejected', $student_id, $course_id); - when teacher rejects student's enrollment in a course. Passes student ID and course ID.

do_action('namaste_started_lesson', $user_id, $lesson_id); - when student starts to read a lesson. Passes the student ID and lesson ID. It's called only once - when the student starts the lesson for the first time.

do_action('namaste_accessed_lesson', $user_id, $lesson_id); - similar to namaste_started_lesson but called each time when student accesses the lesson.

do_action('namaste_completed_lesson', $student_id, $lesson_id); - when student completes a lesson. Passes student ID and lesson ID.

do_action('namaste-lesson-requirements', $post); - called in lessons meta box view just under required homework / test. It lets you specify your custom requirements handled by custom or third party plugins. Note that you must also take care to save these in post meta on the WP "save_post" action. Learn how to do all this in details here.

apply_filters('namaste-lesson-other-requirements', $current_status, $lesson_id, $student_id); - this filter is associated to the above action. It lets you check for unsatisfied completion requirements from other plugins. If your custom plugin defines a requirement and it's not satisfied, it must return true. If the $current_status comes as true you must just return true because this means there is already unsatisfied requirement from other thid-party code.

apply_filters('namaste-lesson-other-todo', $other_todo, $lesson_id, $student_id); - this filter is associated to the "namaste-lesson-requirements" action. It lets you output custom requirements in the lesson's to-do area. Always output each requirement in a "li" tag. Always prepend to $other_todo variable instead of just returning your text, so if there are requirements from other third party plugins, they will also be displayed.

apply_filters('namaste_course_lessons', $lessons, $course_id, $format, $is_module); - lets you filter the lessons for a given module or course.

apply_filters('namaste_studnet_lessons', $lessons, $student_id ) - filter for the specific lessons in the My Courses page. This filter runs after the namaste_course_lessons filter and allows you to futher limit the results for the specific student.

do_action('namaste_achieved_certificate', $student_id, $certificate_id); - when student achieves a certificate. Passes the student ID and certificate ID.

These actions happen when teacher grades student's homework, lesson performance, or performance in a whole course.

do_action('namaste_graded_homework', $solution_id, $grade); - when teacher grades a specific solution to a homework. Passes the solution ID and the grade value as text.

do_action('namaste_graded_course', $student_id, $course_id, $grade); - when teacher grades user's performance on a whole course. Passes the student UD, the course ID and the grade value as text.

do_action('namaste_graded_lesson', $student_id, $lesson_id, $grade); - when teacher grades user's performance on a lesson. Passes the student UD, the lesson ID and the grade value as text.

These actions are called when different pages are displayed. They allow you to add custom content to Namaste pages.

do_action('namaste_extra_th', $page); - allows you to add table header cells on several pages. Currently supports 'homeworks' (the Assignments / Homework admin page) and 'lesson_homeworks' (Assignments for lesson page) passed in the $page paremeter.

do_action('namaste_extra_th', $page, $item); - allows you to add table cells on several pages. Currently supports 'homeworks' (the Assignments / Homework admin page) and 'lesson_homeworks' (Assignments for lesson page) passed in the $page parameter. The $item parameter contains the current record for every row in the table.

do_action('namaste_lms_admin_menu'); - called right after the admin submenu links. Passes no parameters. Allows your plugin to add more submenu links under Namaste! LMS. Be sure to have your action function included in your main plugin file if using this.

do_action('namaste_lms_user_menu'); - similar to above but called on the user menu. Passes no parameters. Allows your plugin to add more submenu links under "My Courses" menu.

Questions? See the About & Contact page