For future reference, this code works.
// Change the button text for lessons containing 'Final Exam' in the title
function custom_llms_quiz_button_text( $text, $quiz_id, $lesson ) {
// Get the lesson post object using the lesson ID
$lesson_post = get_post( $lesson->ID );
// Check if the lesson title contains 'Final Exam' (case insensitive)
if ( stripos( $lesson_post->post_title, 'Final Exam' ) !== false ) {
// Change the button text
if ( 'Take Quiz' === $text ) {
return __( 'Take Final Exam', 'lifterlms' );
} elseif ( 'Start Quiz' === $text ) {
return __( 'Start Final Exam', 'lifterlms' );
}
}
// Return the original text if no changes are made
return $text;
}
add_filter( 'lifterlms_start_quiz_button_text', 'custom_llms_quiz_button_text', 10, 3 );
// Function to change the button text for the 'Start Quiz' button
function custom_llms_begin_quiz_button_text( $text, $quiz, $lesson ) {
// Get the lesson post object using the lesson ID
$lesson_post = get_post( $lesson->ID );
// Check if the lesson title contains 'Final Exam' (case insensitive)
if ( stripos( $lesson_post->post_title, 'Final Exam' ) !== false ) {
// Change the button text
if ( 'Start Quiz' === $text ) {
return __( 'Start Final Exam', 'lifterlms' );
}
}
// Return the original text if no changes are made
return $text;
}
add_filter( 'lifterlms_begin_quiz_button_text', 'custom_llms_begin_quiz_button_text', 10, 3 );