Thank you for waiting, I did some testing around how LearnDash handles the connection between the certificates and the course.
On my test website, I was able to get the value of a custom field added by Toolset Types ( e.g. 'irs-certificate-info' ) from the Course, into the certificate, dynamically.
In the active theme's 'functions.php' file, I included this code:
// get ID of the course by Title
function custom_get_course_id_by_title( string $title = '' ): int {
$posts = get_posts(
array(
'post_type' => 'sfwd-courses',
'title' => $title,
'numberposts' => 1,
'update_post_term_cache' => false,
'update_post_meta_cache' => false,
'orderby' => 'post_date ID',
'order' => 'ASC',
'fields' => 'ids'
)
);
return empty( $posts ) ? get_the_ID() : $posts[0];
}
// Get course field value shortcode
add_shortcode('custom_get_course_field_value', 'custom_get_course_field_value_func');
function custom_get_course_field_value_func($atts) {
$data = shortcode_atts( array(
'field' => ''
), $atts );
$course_title = do_shortcode('[courseinfo show="course_title"]');
$course_id = custom_get_course_id_by_title($course_title);
$course_field_value = do_shortcode("[types field='".$data['field']."' suppress_filters='true' item='".$course_id."'][/types]");
return $course_field_value;
}
This registers a custom shortcode [custom_get_course_field_value] that accepts the attribute 'field', to specify the slug of the target field.
For example, to get the value from the course field with slug 'irs-certificate-info', you can use this shortcode in your certificate builder:
[custom_get_course_field_value field='irs-certificate-info']
I've tested this to work successfully, when the certificate is downloaded from the course page and the quiz page, after successful completion of the course/quiz.
Note: Please make sure that the course, quiz, and certificates are correctly selected in each other's settings.
The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/