LMS & eLearning

Building a Custom Learner Dashboard Page for LearnDash

Build a learner dashboard that opens with a resume button, in-progress courses, completed courses and recent quiz results, first from core LearnDash shortcodes and then with a small custom shortcode.

Building a Custom Learner Dashboard Page for LearnDash

LearnDash 4.18.0.1 ships a profile shortcode, a course list, a resume button and several status shortcodes, but no page called "dashboard". Most sites want one: a single place a learner lands after login that answers "what should I do next" before anything else. This tutorial builds that page in two passes. The first uses only core shortcodes and takes ten minutes. The second adds one custom shortcode for the parts the core blocks cannot do, such as a "next step" card and a recent results list, using documented LearnDash functions.

What a good dashboard answers

Before placing blocks, decide what the page is for. Learner dashboards that work tend to answer four questions in this order: where do I continue, what am I in the middle of, what have I finished, and how did I do. Everything else, such as account settings, certificates and catalog suggestions, belongs lower on the page or on other pages. Keeping that order also keeps the page fast, because the heaviest element, the full profile list, ends up at the bottom where it can be paginated.

Pass one: core shortcodes only

Create a page called Dashboard and add these blocks or shortcodes in order:

[ld_course_resume]

[ld_course_list mycourses="enrolled" status="in_progress,not_started" progress_bar="true" course_grid="false"]

[ld_course_list mycourses="enrolled" status="completed" course_grid="false"]

[ld_user_course_points]

[ld_profile show_search="no" show_header="yes" per_page="5"]

Each one does a specific job:

  • Resume. [ld_course_resume] prints a button to the step the learner last worked on. With no course_id, it falls back to learndash_get_last_active_course(), which reads the newest course row in the activity table that is not yet completed, then learndash_user_course_last_step() for the step. Its attributes are course_id, user_id, label, html_class (default ld-course-resume), html_id and button. When the learner has no active course it prints nothing, which is what you want on a first visit.
  • In progress. The course list's status attribute accepts completed, in_progress and not_started, comma separated, and only applies with mycourses="enrolled". Listing in-progress and not-started together gives the "to do" list. Setting course_grid="false" stops the Course Grid add-on, if installed, from replacing the core template.
  • Completed. The same shortcode with status="completed" keeps finished courses out of the way but reachable.
  • Points. [ld_user_course_points] prints the learner's course points total; skip it if your courses do not award points.
  • Profile. [ld_profile] lists every enrolled course with expandable progress and quiz attempts. Its attributes include per_page, order, orderby, show_header, show_quizzes, show_search, course_points_user, expand_all and profile_link. Five per page keeps the dashboard light.

That page already answers the four questions. The shortcode reference in our LearnDash shortcodes cheat sheet lists the remaining options, and building a student profile page goes deeper into the profile block alone.

Pass two: a custom summary shortcode

Core shortcodes cannot show "your next lesson is X in course Y" as a card, nor a short list of recent quiz scores. A small shortcode covers both:

<?php
/**
 * Build an escaped anchor for the dashboard.
 *
 * @param string $url   Link target.
 * @param string $text  Link text.
 * @param array  $attrs Extra attributes.
 * @return string
 */
function wwc_dash_link( $url, $text, $attrs = array() ) {
    $attrs     = array_merge( array( 'href' => esc_url( $url ) ), $attrs );
    $attr_html = '';
    foreach ( $attrs as $attr_name => $attr_value ) {
        $attr_html .= sprintf( ' %1$s="%2$s"', esc_attr( $attr_name ), esc_attr( $attr_value ) );
    }
    return '<a' . $attr_html . '>' . esc_html( $text ) . '</a>';
}

/**
 * [wwc_dashboard_summary] - next step card and recent quiz results.
 */
function wwc_dashboard_summary_shortcode() {
    if ( ! is_user_logged_in() ) {
        return '';
    }

    $user_id   = get_current_user_id();
    $course_id = learndash_get_last_active_course( $user_id );
    $html      = '<div class="wwc-dash">';

    if ( $course_id ) {
        $step_id = learndash_user_progress_get_first_incomplete_step( $user_id, $course_id );
        $percent = learndash_course_progress(
            array(
                'user_id'   => $user_id,
                'course_id' => $course_id,
                'array'     => true,
            )
        );

        $html .= '<section class="wwc-dash__next">';
        $html .= '<h2>' . esc_html__( 'Up next', 'wwc' ) . '</h2>';
        $html .= '<p class="wwc-dash__course">' . esc_html( get_the_title( $course_id ) ) . ' &middot; ' . absint( $percent['percentage'] ?? 0 ) . '%</p>';

        if ( $step_id ) {
            $html .= wwc_dash_link(
                learndash_get_step_permalink( $step_id, $course_id ),
                get_the_title( $step_id ),
                array( 'class' => 'ld-button' )
            );
        }

        $html .= '</section>';
    }

    $attempts = get_user_meta( $user_id, '_sfwd-quizzes', true );

    if ( is_array( $attempts ) && ! empty( $attempts ) ) {
        usort(
            $attempts,
            function ( $a, $b ) {
                return (int) ( $b['time'] ?? 0 ) - (int) ( $a['time'] ?? 0 );
            }
        );

        $html .= '<section class="wwc-dash__results"><h2>' . esc_html__( 'Recent results', 'wwc' ) . '</h2><ul>';

        foreach ( array_slice( $attempts, 0, 5 ) as $attempt ) {
            $html .= sprintf(
                '<li>%1$s: %2$s%% %3$s</li>',
                esc_html( get_the_title( $attempt['quiz'] ) ),
                esc_html( round( (float) ( $attempt['percentage'] ?? 0 ) ) ),
                ! empty( $attempt['pass'] ) ? esc_html__( '(passed)', 'wwc' ) : esc_html__( '(not passed)', 'wwc' )
            );
        }

        $html .= '</ul></section>';
    }

    return $html . '</div>';
}
add_shortcode( 'wwc_dashboard_summary', 'wwc_dashboard_summary_shortcode' );

Place [wwc_dashboard_summary] at the top of the page in place of the resume button. A few notes on the functions:

  • learndash_user_progress_get_first_incomplete_step( $user_id, $course_id ) returns the first step the learner has not completed in course order. That is a better "up next" for linear courses than the last step visited, which may be a lesson they already finished. For free-form courses the resume button's "last visited" logic may suit learners better; the difference is explained in our guide to next and previous step functions.
  • learndash_course_progress() with 'array' => true returns percentage, completed and total without printing anything and without writing progress.
  • Quiz attempts come from the _sfwd-quizzes user meta, where each entry has quiz, percentage, pass and time keys among others. Sorting by time gives the newest first.

Adding the stats row from the profile

The profile header shows courses, completed, certificates and points. Its array passes through the filter learndash_profile_stats with the user ID, so you can add your own tile, for example quizzes passed, and it appears wherever the profile header renders, including on the dashboard:

<?php
add_filter(
    'learndash_profile_stats',
    function ( $stats, $user_id ) {
        $attempts = get_user_meta( $user_id, '_sfwd-quizzes', true );
        $passed   = is_array( $attempts ) ? count( array_filter( wp_list_pluck( $attempts, 'pass' ) ) ) : 0;

        $stats[] = array(
            'title' => esc_html__( 'Quizzes passed', 'wwc' ),
            'value' => $passed,
            'class' => 'ld-profile-stat-quizzes-passed',
        );

        return $stats;
    },
    10,
    2
);

Sending learners to the dashboard

A dashboard only helps if learners arrive there. Redirect logins to it with the login_redirect filter, and point the account link in your menu at it rather than at the WordPress profile. If you prefer learners to land straight in their last course, the pattern in redirecting users to their last active course does that instead; many sites redirect first-time users to the dashboard and returning users to the last course.

Access and caching

Restrict the page to logged-in users with your membership plugin or a simple check in the theme template that redirects visitors to the login page. Exclude it from page caching, since everything on it is personal; a cached dashboard is the most common way learners end up seeing someone else's progress. The shortcodes themselves are cheap except the profile, which loads every enrolled course; the per_page attribute keeps that in check.

Styling

The core shortcodes render inside .learndash-wrapper and pick up the LearnDash colour settings. Give your custom sections matching spacing and use .ld-button for the up-next link, as above, so it inherits the accent colour. A two-column layout with the up-next card and results on one side and the in-progress list on the other works well on desktop, collapsing to one column on phones.

Testing

Check four learners: a brand-new user with no enrollments, who should see only the course lists' empty states; a learner part-way through one course; a learner with several courses, one completed; and one who has taken quizzes and failed some. Confirm the up-next link opens the right step, the completed list shows only finished courses, and recent results are newest first. Then log in as an administrator and confirm nothing on the page leaks another user's data.

When to get help

The shortcode page takes minutes and the summary shortcode an hour. Dashboards with cohort calendars, live session links, recommendations or data from outside LearnDash are larger builds; our LearnDash services team designs and builds them with UI and UX design, and a LearnDash developer can turn the page into a block with editor controls.

Frequently asked questions

Does LearnDash have a built-in learner dashboard?

No single dashboard page exists in core. The profile shortcode is the closest; combining it with the resume button and filtered course lists gives a dashboard without code.

How do I list only courses a learner has not finished?

Use [ld_course_list mycourses="enrolled" status="in_progress,not_started"]. The status attribute only applies when mycourses is set to enrolled.

Why does the resume button not appear?

It prints nothing when the learner has no incomplete course in the activity table, for example a new user or one who has finished everything.

Can I add my own figures to the profile stats?

Yes. Append items with title, value and class keys through the learndash_profile_stats filter.

Add WorldWin Coder to your preferred sources

Add worldwincoder.com as a preferred source on Google, or open this article in your AI assistant to use it as a source.

· Developers and project managers

Articles written and reviewed by the developers and project managers at WorldWin Coder, who build and maintain websites, web applications and mobile apps on WordPress, Moodle, PHP, Laravel, CodeIgniter and Flutter.

Free consultation

Need help with LearnDash?

Tell us what you are working on. A developer who does this every week reads your message and replies within one business day with next steps and a free quote.

  • Free consultation and quote
  • NDA on request
  • You own the source code
  • Reply within one business day

Tell us about your project

Add budget and timeline optional, helps us quote faster

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Keep reading

Have something to build, fix or move?

Tell us where you are. A developer reads every inquiry, and you get next steps and a free quote within one business day.