Hi @dartanidi,
In this case, the following JavaScript code snippet below will redirect the student to Google once the course is complete. So you just need to replace "https://www.google.com/"
with your desired URL inside double quotes. To add the code below to your site, please follow the instructions in lifterlms.com/docs/how-do-i-add-custom-code-to-lifterlms/#code-snippets.
add_action( "wp_footer", "custom_redirect_logic_for_lessons", PHP_INT_MAX );
function custom_redirect_logic_for_lessons() {
if ( is_singular( "lesson" ) ):
?>
<script type="text/javascript">
(function($){
$(document).ready(function(){
var notificationsDisplayed = false;
var progress = '0%';
var count = 0;
/* Check that we are in the last lesson of a course. */
if ( 0 == $(".llms-next-lesson").length ) {
/* Create the timer only when we are on the last lesson of a course. */
var timer = setInterval(function() {
console.log("Timer running.");
/* Every increment of 1 corresponds to 100 milliseconds. */
count += 1;
console.log('count: ', count);
/* Always check the current value of the progress bar. */
if ( $('.progress-bar-complete').length > 0 ) {
progress = $('.progress-bar-complete').data('progress');
}
if ( '100%' != progress && count >= 10 ) {
clearInterval(timer);
console.log("Timer not running.");
}
/* Once the notifcation has been set to true, do not change it. */
if ( $(".llms-notification.visible").length > 0 && false == notificationsDisplayed ) {
notificationsDisplayed = true;
}
/* If notifications are not displayed within the first 1 second, stop the timer. */
if ( !notificationsDisplayed && count >= 10 ) {
clearInterval(timer);
console.log("Timer not running.");
}
/* If notifications are displayed let's wait for 1 second before redirecting. */
if ( notificationsDisplayed && count >= 10 ) {
/* Don't redirect unless notifications have been displayed in the same viewing session. */
if ( '100%' == progress && notificationsDisplayed ) {
clearInterval(timer);
console.log("Timer not running.");
window.location.replace("https://www.google.com/");
}
}
}, 100);
}
});
})(jQuery);
</script>
<?php
endif;
}