Skip to content

Instantly share code, notes, and snippets.

@tpkemme
Created February 17, 2017 08:35
Show Gist options
  • Save tpkemme/949f6e41cb46b1313a20e0f534edfec3 to your computer and use it in GitHub Desktop.
Save tpkemme/949f6e41cb46b1313a20e0f534edfec3 to your computer and use it in GitHub Desktop.
This filter for the LifterLMS Plugin lets you change the text of the Mark Complete button, but only for a specific course.
<?php // don't copy this line!!!
/**
* Displays custom text for the Mark Complete button but only for a
* specific course
*
* Added: 2-17-2017 Tyler Kemme
*/
function custom_mark_complete_text( $button_text, $lesson ) {
// CHANGE THE TEXT FOR THE MARK COMPLETE BUTTON HERE!!!
$custom_buttom_text = 'Custom Mark Complete Text Goes Here';
// ID of the course containing this lesson
$courseId = $lesson->get_parent_course();
// Only change the button text if this courseId matches the courseId
// of the course we're going to change
//
// In this example, only the course with the id of 55 will get the custom button text
// we made above
if( $courseId == 55 ){
return $custom_buttom_text;
}
// All other course get the default mark complete button Text
else{
return 'Mark Complete';
}
}
add_filter( 'lifterlms_mark_lesson_complete_button_text', 'custom_mark_complete_text', 15, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment