Last active
March 30, 2022 03:53
-
-
Save Anshu-wwc/082a2558a9e9c34879a95256725b70bb to your computer and use it in GitHub Desktop.
Update Course/Lesson Start/End Time Learnpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $user_id = !empty( $_POST['user_id']) ? $_POST['user_id']: ''; | |
| $course_id = !empty( $_POST['course_id'] ) ? $_POST['course_id'] : ''; | |
| $complete_date = !empty( $_POST['com_date'] ) ? $_POST['com_date'] : ''; | |
| // change date format | |
| $com_date = DateTime::createFromFormat('Y-m-d\TH:i:s', $complete_date); | |
| $dt = $com_date->format('Y-m-d H:i:s'); | |
| $profile = learn_press_get_profile($user_id); | |
| $query = $profile->query_courses('purchased'); | |
| $course_applied = learn_press_get_user($user_id, false); | |
| // Course Data Object | |
| $course_data = $course_applied->get_course_data($course_id); | |
| $start_time = $course_data->set_start_time( $dt ); | |
| $start_time = $course_data->set_end_time( $dt ); | |
| // Save the edits made | |
| $course_data->update(); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment