Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save actual-saurabh/602966b30ce0621d9d8ac281a076b923 to your computer and use it in GitHub Desktop.
Save actual-saurabh/602966b30ce0621d9d8ac281a076b923 to your computer and use it in GitHub Desktop.
LifterLMS Custom Merge Codes for Certificates
<?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_certificate_prefix_suffix_merge_codes', 10, 2 );
function llms_custom_certificate_title_merge_code( $merge_codes_array, $certificate_object ){
// add custom certificate title merge code to existing ones. See https://github.com/gocodebox/lifterlms/blob/a1a6833c6e6bab57bf4356739463220e51f89408/includes/certificates/class.llms.certificate.user.php#L132
$merge_codes_array['{merge-code-1}'] = get_user_meta( $certificate_object->user_id, 'custom_field_key_1', true );
// repeat for each merge code.
$merge_codes_array['{merge-code-2}'] = get_user_meta( $certificate_object->user_id, 'custom_field_key_2', true );
// return new merge code list
return $merge_codes_array;
}
add_filter( 'llms_merge_codes_for_button', 'llms_custom_certificate_prefix_suffix_merge_codes_for_button', 10, 2 );
function llms_custom_certificate_title_merge_code_for_button( $codes, $screen ){
// don't run on emails
if( $screen->post_type != 'llms_certificate' ){
return;
}
// the merge code and the text displayed on the button.
$codes['{merge-code-1}'] = "Merge Code 1";
// repeat for each merge code.
$codes['{merge-code-2}'] = "Merge Code 2";
return $codes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment