Skip to content

Instantly share code, notes, and snippets.

@steveclason
Created September 6, 2021 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveclason/e38f6636806a5bbc1a0c88c8e34057df to your computer and use it in GitHub Desktop.
Save steveclason/e38f6636806a5bbc1a0c88c8e34057df to your computer and use it in GitHub Desktop.
LearnDash, WordPress, add serial number to certificate.
<?php
/**
* LearnDash in WordPress
* Display a serial number on the printed course certificate. Serial number is a concatenation of user_id abd certificate_id.
* Attribute stuff is there just in case, does nothing now.
* I usually put shortcodes in a shortcodes.php file and require it in functions.php, but whatever.
*/
if ( !function_exists ( 'ce_cert_serialize_function' )) {
function ce_cert_serialize_function( $atts ) {
$a = shortcode_atts( array(
// default attributes
// 'callout_title' => 'No Title'
), $atts );
// TODO Concatenate userid abnd courseid?
$user_id = get_current_user_id();
$cert_id = get_the_id();
// $html = '<p>ABC123</p>';
$html = 'Certificate No. ' . $user_id . '-' . $cert_id;
return $html;
} // shortcode function.
} // function_exists.
add_shortcode( 'cert_serialize', 'ce_cert_serialize_function' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment