Title: sdwarwick's Replies | WordPress.org

---

# sdwarwick

  [  ](https://wordpress.org/support/users/sdwarwick/)

 *   [Profile](https://wordpress.org/support/users/sdwarwick/)
 *   [Topics Started](https://wordpress.org/support/users/sdwarwick/topics/)
 *   [Replies Created](https://wordpress.org/support/users/sdwarwick/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/sdwarwick/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/sdwarwick/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/sdwarwick/engagements/)
 *   [Favorites](https://wordpress.org/support/users/sdwarwick/favorites/)

 Search replies:

## Forum Replies Created

Viewing 15 replies - 1 through 15 (of 15 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Dealing with end-of-course redirect](https://wordpress.org/support/topic/dealing-with-end-of-course-redirect/)
 *  Thread Starter [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/dealing-with-end-of-course-redirect/#post-9019361)
 * I’ve confirmed that this new hook works as desired, thanks for the sample code.
   for those reading this, please look to using the new hook rather than the workaround
   as described in the initial post
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Dealing with end-of-course redirect](https://wordpress.org/support/topic/dealing-with-end-of-course-redirect/)
 *  Thread Starter [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/dealing-with-end-of-course-redirect/#post-9016736)
 * yes, this is all about how “get_next_lesson” works and how you deal with what
   happens if there isn’t a next lesson.
 * I am actually surprised that this is not a very common concern, but so be it.
 * I’d be interested in perhaps chatting sometime to discuss the broader use of 
   custom meta variables as an intermediate approach to providing “post level” special
   processing. I’m using it a lot now.. my “hide mark complete” is activated from
   a meta variable in the lesson. it seems like a nice low-overhead mechanism for
   control at the user-interface level. in addition, it doesn’t require tying special
   processing to a specific post/lesson ID.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Automatically mark lessons complete](https://wordpress.org/support/topic/automatically-mark-lessons-complete/)
 *  [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/automatically-mark-lessons-complete/#post-9016710)
 * [@thomasplevy](https://wordpress.org/support/users/thomasplevy/) – I’m always
   grateful for the work you do to make lifter a great product. I see providing 
   specific opportunities for improvement as the most effective way to support those
   efforts!
 * I’ll look at a developing a pull request.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Correct implementation of new mark_complete()](https://wordpress.org/support/topic/correct-implementation-of-new-mark_complete/)
 *  [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/correct-implementation-of-new-mark_complete/#post-9010365)
 * you may run into problems with the above code, as get_the_ID() may return an 
   undefined value when sending an ajax call.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Automatically mark lessons complete](https://wordpress.org/support/topic/automatically-mark-lessons-complete/)
 *  [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/automatically-mark-lessons-complete/#post-9003958)
 * so, I have been using something very similar to these concepts for a while now.
   essentially hid the “mark complete” button and fired the mark_complete form using
   a jquery “click”
 * this does two things nicely – registers completion and serves the “next” lesson.
 * EXCEPT!! the last lesson in the course gets stuck. rather than a default for 
   end-of-course, you just send back the same url. Of course, the second time, the
   mark complete button is removed since now it is considered a “completed” lesson.
   but still, users see the last lesson twice, which is a real bummer when it is
   a final exam!!
 * you have a very simple opportunity to add a hook in the following code for get
   next lesson… I am at a loss right now how to deal with this other than literally
   removing the mark_complete action from init and adding a custom version that 
   provides an end-of-course option. the approach would be to detect a null on next
   lesson and provide an alternative
 *     ```
       	public function get_next_lesson() {
   
       		$parent_section = $this->get_parent_section();
       		$current_position = $this->get_order();
       		$next_position = $current_position + 1;
   
       		$args = array(
       			'posts_per_page' 	=> 1,
       			'post_type' 		=> 'lesson',
       			'nopaging' 			=> true,
       			'post_status'   	=> 'publish',
       			'meta_query' 		=> array(
       				'relation' => 'AND',
       				array(
       				    'key' => '_llms_parent_section',
       				    'value' => $parent_section,
       				    'compare' => '=',
       			    ),
       			    array(
       				    'key' => '_llms_order',
       				    'value' => $next_position,
       				    'compare' => '=',
       			    )
       			),
       		);
       		$lessons = get_posts( $args );
   
       		//return the first one even if there for some crazy reason were more than one.
       		if ( $lessons ) {
       			return $lessons[0]->ID;
       		} else {
       			// See if there is another section after this section and get first lesson there
       			$parent_course = $this->get_parent_course();
       			$cursection = new LLMS_Section( $this->get_parent_section() );
       			$current_position = $cursection->get_order();
       			$next_position = $current_position + 1;
   
       			$args = array(
       				'post_type' 		=> 'section',
       				'posts_per_page'	=> 500,
       				'meta_key'			=> '_llms_order',
       				'order'				=> 'ASC',
       				'orderby'			=> 'meta_value_num',
       				'meta_query' 		=> array(
       					'relation' => 'AND',
       					array(
       					    'key' => '_llms_parent_course',
       					    'value' => $parent_course,
       					    'compare' => '=',
       				    ),
       				    array(
       					    'key' => '_llms_order',
       					    'value' => $next_position,
       					    'compare' => '=',
       				    )
       				),
       			);
       			$sections = get_posts( $args );
   
       			if ( $sections ) {
       				$newsection = new LLMS_Section( $sections[0]->ID );
       				$lessons = $newsection->get_children_lessons();
       				if ( $lessons ) {
       					return $lessons[0]->ID;
       				} else {
       					return false;
       				}
       			} else {
       		return false;   // no! no! no!!   
       			}
       		}
       	}
       ```
   
    -  This reply was modified 9 years, 2 months ago by [sdwarwick](https://wordpress.org/support/users/sdwarwick/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Is There a Course Completion Page?](https://wordpress.org/support/topic/is-there-a-course-completion-page/)
 *  [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/is-there-a-course-completion-page/#post-8806777)
 * Lifterlms has an extensive “prerequisite” system so that you can set up a final
   lesson that acknowledges completion of the prior lessons. Are you using that?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Is There a Course Completion Page?](https://wordpress.org/support/topic/is-there-a-course-completion-page/)
 *  [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/is-there-a-course-completion-page/#post-8804272)
 * Not sure exactly what you are looking for, however I do believe that if you have
   the ability to add an additional “lesson” page to your site after the quiz, it
   is possible to add a very small function that looks for a tag on that page and
   redirects immediately to another page on the site.
 * since lifter naturally moves to the next lesson in a course, putting this page
   at the end would enable the desired behavior.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Cloning course?](https://wordpress.org/support/topic/cloning-course/)
 *  [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/cloning-course/#post-8790598)
 * Any chance of extending that capability to cloning individual Lessons?
    this 
   may not seem a needed item on initial look, however I’ve got lessons with a lot
   of configuration. no comments xapi settings special variables set prerequisites
   etc..
 * it would be nice to start each lesson off from the last one.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Delete all student progress when unenrolling student](https://wordpress.org/support/topic/delete-all-student-progress-when-unenrolling-student/)
 *  Thread Starter [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/delete-all-student-progress-when-unenrolling-student/#post-8782679)
 * Here is something I came up with – would appreciate a review/comment
 *     ```
       add_action( 'llms_user_removed_from_course', 'clear_enrollment_data', 10, 2 );
   
       function clear_enrollment_data($uid, $product_id)
       {
           global $wpdb;
   
           $course = new LLMS_Course( $product_id);
       	$lessons = $course->get_lessons( 'ids' );
   
           foreach ($lessons as $lesson) {
           $update = $wpdb->delete( $wpdb->prefix . 'lifterlms_user_postmeta',
                           array(
                               'user_id'      => $uid,
                               'post_id'      => $lesson  
                           ),
                           array( '%d', '%d' )
                       );
   
           }
   
                       return;
       };
       ```
   
    -  This reply was modified 9 years, 4 months ago by [sdwarwick](https://wordpress.org/support/users/sdwarwick/).
    -  This reply was modified 9 years, 4 months ago by [sdwarwick](https://wordpress.org/support/users/sdwarwick/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Need code to auto-enroll after registration](https://wordpress.org/support/topic/need-code-to-auto-enroll-after-registration/)
 *  Thread Starter [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/need-code-to-auto-enroll-after-registration/#post-8755161)
 * try that again:
 *     ```
       // auto-enroll in specific course called Improve IT
       add_action('lifterlms_user_registered', 'addUserToCourse', 10, 1);
       function addUserToCourse($personID)
       {
           $postTypes = array('post_type'=>'course','meta_key'=>'autoEnroll','meta_value' =>'true');
           $postList = get_posts($postTypes);
           foreach ($postList as $post) {
               llms_enroll_student( $personID, $post->ID, 'registered' ) ;
           }
       };
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Need code to auto-enroll after registration](https://wordpress.org/support/topic/need-code-to-auto-enroll-after-registration/)
 *  Thread Starter [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/need-code-to-auto-enroll-after-registration/#post-8753433)
 * For folks interested in this kind of behavior, here is what I ended up doing.
   I add a “Custom Field” to courses that I want auto enrolled with the key “autoEnroll”
   and the value “true”
 * when someone registers, all courses with that field are auto-enrolled.
 * the following is added to functions.php :
 *     ```
       // auto-enroll in specific course
       add_action('lifterlms_user_registered', 'addUserToCourse', 10, 1);
       function addUserToCourse($personID)
       {
           $postList = array('post_type'=>'course','meta_key'=>'autoEnroll','meta_value' =>'true');
           foreach ($postList as $post) {
               llms_enroll_student( $personID, $post->ID, 'registered' ) ;
           }
       }
       ```
   
 * Note that I do not check to see if the person is already enrolled on the assumption
   that newly registered people are not enrolled in anything by default.
    -  This reply was modified 9 years, 4 months ago by [sdwarwick](https://wordpress.org/support/users/sdwarwick/).
    -  This reply was modified 9 years, 4 months ago by [sdwarwick](https://wordpress.org/support/users/sdwarwick/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Need code to auto-enroll after registration](https://wordpress.org/support/topic/need-code-to-auto-enroll-after-registration/)
 *  Thread Starter [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/need-code-to-auto-enroll-after-registration/#post-8746053)
 * This is perfect!
 * Thanks for the recommended hook as well.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes] Need code to auto-enroll after registration](https://wordpress.org/support/topic/need-code-to-auto-enroll-after-registration/)
 *  Thread Starter [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/need-code-to-auto-enroll-after-registration/#post-8742439)
 * For Lifterlms!
 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [[Customizr] responsive nav menu behavior broken?](https://wordpress.org/support/topic/responsive-nav-menu-behavior-broken/)
 *  Thread Starter [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/responsive-nav-menu-behavior-broken/#post-5855234)
 * Thank you so much for this response. I would not have been able to find this 
   solution without many hours of digging, if at all. If no one has said this recently,
   your help is so very much appreciated!
 * I have chosen the second solution, as having the collapsed but active nav is 
   very useful and does not interfere with how the top bar looks.
 * Is this a bug that ends up as a fix in the next version? if so, how do you handle
   these two optional behaviors?
 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [[Customizr] responsive nav menu behavior broken?](https://wordpress.org/support/topic/responsive-nav-menu-behavior-broken/)
 *  Thread Starter [sdwarwick](https://wordpress.org/support/users/sdwarwick/)
 * (@sdwarwick)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/responsive-nav-menu-behavior-broken/#post-5855228)
 * Thanks for your response. I am still confused as to how this function should 
   work.
 * It would seem that under all circumstances when you have scrolled back up and
   a menu is available, it should function. As it is now, after any scrolling activity
   the menu never gets reactivated
 * The only way to get the menu working again is to reload the page, which is not
   intuitive to users.
 * Not sure how to even debug this, it would be buried deep in the code

Viewing 15 replies - 1 through 15 (of 15 total)