Skip to content

Shortcode Development

LearnDash Dashboard registers 9 shortcodes through the Ld_Dashboard_Shortcodes singleton. All shortcodes use output buffering and support theme template overrides.


Renders the main frontend dashboard panel.

Attributes: None

Behavior:

  • Shows a login notice and link for logged-out users (filterable via ld_dashboard_login_notice and ld_dashboard_login_link).
  • Loads templates/ld-dashboard.php (or theme override).
  • Displays role-appropriate tabs and content.

Template: templates/ld-dashboard.php

echo do_shortcode( '[ld_dashboard]' );

Displays the instructor application/registration form.

Attributes: None (delegates to LD_Dashboard_Instructor_Manager::registration_form())

Behavior: Shows the registration form to non-instructors. Logged-in instructors see a message that they are already registered.


Displays a paginated, searchable grid of all instructors.

Attributes:

Attribute Default Description
col 4 Number of grid columns

Filters available:

  • ld_dashboard_instructors_columns — Modify column count.
  • ld_dashboard_instructors_per_page — Items per page (default: 12).
  • ld_dashboard_instructors_list — Filter the instructor WP_User array.
  • ld_dashboard_instructor_data — Filter individual instructor data.
  • ld_dashboard_instructor_courses — Filter courses shown per instructor.
  • ld_dashboard_instructor_avatar — Filter instructor avatar HTML.
  • ld_dashboard_instructor_name — Filter instructor display name.

If the URL matches an instructor profile (via instructor_username query var), a single instructor profile is shown instead of the grid.

Actions:

  • ld_dashboard_before_single_instructor — Fires before single instructor template.
  • ld_dashboard_after_single_instructor — Fires after single instructor template.

Templates:

  • Grid: No template file (inline output).
  • Single profile: templates/ld-dashboard-single-instructor.php.

Displays student progress details. Visible to instructors, group leaders, and administrators only.

Attributes: None

Template: templates/ld-dashboard-student-status.php


Displays the email integration interface for sending bulk emails to students.

Attributes: None

Visibility: Only shown when the enable-email-integration general setting is enabled and the user is an instructor, group leader, or administrator.

Template: templates/ld-dashboard-email-integration.php


Displays an enrollment code redemption widget for logged-in users.

Attributes: None

Behavior: Returns empty string for logged-out users. Enqueues ld-dashboard-enrollment-codes style and script.

Template: templates/dashboard-widgets/enrollment-code-redeem.php


Displays a list of Zoom meetings. Requires the Zoom module to be active.

Attributes:

Attribute Default Description
id Meeting post ID
title Details Section title

Template: templates/ld-dashboard-meeting-shortcode.php


Displays a single Zoom meeting detail view.

Attributes:

Attribute Default Description
id Meeting post ID
title Details Section title

Template: templates/ld-dashboard-single-meeting.php


Embeds a Zoom meeting via iframe or SDK.

Attributes:

Attribute Default Description
meeting_id Zoom meeting ID
height 500px Frame height
iframe yes Enable iframe embed
disable_countdown no Disable pre-join countdown

Zoom shortcodes only render when ld_dashboard_is_zoom_enabled() returns true.


All shortcodes use Ld_Dashboard_Shortcodes::locate_template() to find templates. The lookup order is:

  1. Active child theme: {child-theme}/ld-dashboard/{template-name}
  2. Active parent theme: {parent-theme}/ld-dashboard/{template-name}
  3. Plugin: {plugin}/templates/{template-name}

To override a template, copy it from the plugin’s templates/ directory to your theme’s ld-dashboard/ directory.

mytheme/
└── ld-dashboard/
└── ld-dashboard.php # Overrides main dashboard template
└── ld-dashboard-student-status.php

All shortcode render methods use WordPress’s recommended output buffering pattern:

public function render_my_shortcode( $atts, $content = '' ) {
ob_start();
// Template or inline output.
$template = $this->locate_template( 'my-template.php' );
if ( $template ) {
include $template;
}
return ob_get_clean();
}

This ensures shortcodes return HTML rather than echo it directly, which is required for correct WordPress shortcode behavior.


Shortcodes perform role checks before rendering content:

// Check if user is an instructor, group leader, or admin.
if (
! learndash_is_group_leader_user()
&& ! learndash_is_admin_user()
&& ! LD_Dashboard_Helper::is_instructor()
) {
return ''; // Return empty for students.
}

The [ld_dashboard] shortcode shows a login prompt for logged-out users rather than returning empty.


You can add custom shortcodes that integrate with the dashboard’s template system by hooking into WordPress’s add_shortcode during init. You can also extend Ld_Dashboard_Shortcodes if you need access to locate_template().

add_action( 'init', function() {
add_shortcode( 'my_dashboard_widget', function( $atts ) {
// Only for logged-in users.
if ( ! is_user_logged_in() ) {
return '';
}
$atts = shortcode_atts(
array( 'title' => __( 'My Widget', 'my-plugin' ) ),
$atts
);
ob_start();
// Check theme override first.
$theme_template = get_stylesheet_directory() . '/ld-dashboard/my-widget.php';
$plugin_template = MY_PLUGIN_DIR . 'templates/my-widget.php';
if ( file_exists( $theme_template ) ) {
include $theme_template;
} elseif ( file_exists( $plugin_template ) ) {
include $plugin_template;
}
return ob_get_clean();
} );
} );

Within your template file, you have access to $atts (shortcode attributes) and all standard WordPress globals.