Skip to content

Instantly share code, notes, and snippets.

@actual-saurabh
Last active May 29, 2018 12:43
Show Gist options
  • Save actual-saurabh/ad74bbe12993f06f5f04aa9dce7f9637 to your computer and use it in GitHub Desktop.
Save actual-saurabh/ad74bbe12993f06f5f04aa9dce7f9637 to your computer and use it in GitHub Desktop.
Custom Merge Code for Course Title
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
add_filter( 'llms_certificate_merge_codes', 'llms_custom_course_title_merge_code', 10, 2 );
function llms_custom_course_title_merge_code( $merge_codes_array, $certificate_object ){
// the triger post's (course's) id is in the lesson_id property of the $certificate_object
$course_title = get_the_title( $certificate_object->lesson_id );
// add custom certificate title merge code to existing ones
$merge_codes_array['{course_title}'] = $course_title;
// return new merge code list
return $merge_codes_array;
}
add_filter( 'llms_merge_codes_for_button', 'llms_custom_course_title_merge_code_for_button', 10, 2 );
function llms_custom_course_title_merge_code_for_button( $codes, $screen ){
// don't run on emails
if( $screen->post_type != 'llms_certificate' ){
return;
}
$codes['{course_title}'] = "Course Title";
return $codes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment