# LearnDash: Course Completion Date Shortcode

> Adds a [wpide_ld_completed_on] shortcode that shows the date the student completed a course, or a "not completed yet" message.

- Type: PHP
- Runs: Run everywhere
- Category: [Courses & Community](https://wpide.com/library/category/learning/)
- Tags: learndash, courses, shortcode
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/learndash-completion-date-shortcode/

## Code

```php
if ( ! defined( 'LEARNDASH_VERSION' ) ) {
    return;
}

add_shortcode( 'wpide_ld_completed_on', function ( $atts ) {
    $atts      = shortcode_atts( array( 'course_id' => 0, 'format' => get_option( 'date_format' ), 'pending' => 'Not completed yet' ), $atts, 'wpide_ld_completed_on' );
    $user_id   = get_current_user_id();
    $course_id = $atts['course_id'] ? absint( $atts['course_id'] ) : (int) learndash_get_course_id( get_the_ID() );

    if ( ! $user_id || ! $course_id ) {
        return '';
    }

    $time = function_exists( 'learndash_user_get_course_completed_date' )
        ? (int) learndash_user_get_course_completed_date( $user_id, $course_id )
        : (int) get_user_meta( $user_id, 'course_completed_' . $course_id, true );

    return esc_html( $time ? wp_date( $atts['format'], $time ) : $atts['pending'] );
} );
```

## Notes

Use course_id="123" outside a course, and format="j F Y" for a custom date format.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "LearnDash: Course Completion Date Shortcode" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
