We can easily show enrolled courses of current logged in users using the ld_profile
shortcode of LearnDash. We can use this shortcode in WooCommerce My Account (user dashboard) page as well.
The ld_profile
shortcode is actually to show user profile, which contains all enrolled courses with progress. This shortcode will output many useful information including user avatar, name, total number of courses enrolled, courses completed, number of certificate earned, list of enrolled courses with ability to search course, course progress, links to download certificates, quizzes taken etc. ld_profile
shortcode has few parameters as well. Full ld_profile
documentation is available here.
So how do we use this easily on WooCommerce my account page/user dashboard? We can use the woocommerce_account_dashboard
action hook to display above shortcode. This will display user profile after texts on my account page.
function careless_display_learndash_user_profile() {
echo '<h1 class="entry-title dashboard-ld-courses">' . __( 'Enrolled Courses', 'woocommerce' ) .'</h1>';
echo do_shortcode('[ld_profile course_points_user="no" show_search="no"]' );
}
add_action( 'woocommerce_account_dashboard', 'careless_display_learndash_user_profile' );
Above code will display user profile without the course points and search form.
Code goes in the functions.php
file of your active theme.