# Tutor LMS: Course Progress Bar Shortcode

> Adds a [wpide_tutor_progress] shortcode that shows the logged-in student's completion percentage for a Tutor LMS course as an accessible progress bar.

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

## Code

```php
if ( ! function_exists( 'tutor_utils' ) ) {
    return;
}

add_shortcode( 'wpide_tutor_progress', function ( $atts ) {
    $atts      = shortcode_atts( array( 'course_id' => 0 ), $atts, 'wpide_tutor_progress' );
    $user_id   = get_current_user_id();
    $course_id = $atts['course_id'] ? absint( $atts['course_id'] ) : ( get_post_type() === tutor()->course_post_type ? get_the_ID() : 0 );

    if ( ! $user_id || ! $course_id || ! tutor_utils()->is_enrolled( $course_id, $user_id ) ) {
        return '';
    }

    $percent = (int) tutor_utils()->get_course_completed_percent( $course_id, $user_id );

    return sprintf(
        '<div class="wpide-tutor-progress"><div role="progressbar" aria-valuenow="%1$d" aria-valuemin="0" aria-valuemax="100" aria-label="%2$s" style="height:10px;border-radius:5px;background:rgba(127,127,127,.25);overflow:hidden"><div style="width:%1$d%%;height:100%%;background:currentColor"></div></div><p style="margin:.4em 0 0;font-size:.9em">%3$s</p></div>',
        $percent,
        esc_attr( get_the_title( $course_id ) . ' progress' ),
        esc_html( sprintf( '%d%% complete', $percent ) )
    );
} );
```

## Notes

On a course page it uses that course; elsewhere add course_id="123".

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tutor LMS: Course Progress Bar 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/
