How to modify Frontend Dashboard in Academy LMS

This documentation provides step-by-step guidance for adding, removing, organizing, and managing the frontend dashboard menu in Academy LMS.

Overview #

The Frontend Dashboard allows developers to customize menu items effectively. You can:

  • Add new menus and submenus.
  • Remove existing menus.
  • Reorder or organize menus based on priority.
  • Hide specific menus from public view.

This flexibility ensures seamless customization to match your specific requirements. To do this in Academy LMS, you need to use an academy filter hook. The hook is:

academy/frontend_dashboard_menu_items.

Adding a Menu #

Use the academy/frontend_dashboard_menu_items filter to modify the current menus. Here’s an example:

add_filter( 'academy/frontend_dashboard_menu_items', 'add_menu' );


function add_menu( $items ) {
   // items without submenu
   $items['demo_item'] = array(
      'label' => __( 'Demo Item', 'academy' ),
      'icon'  => 'academy-icon academy-icon--Lesson',
      'public' => true,
      'priority' => 35,
   );
   // item with submenu
   $items['courses'] = array(
      'label' => __( 'Courses', 'academy' ),
      'icon'  => 'academy-icon academy-icon--course-cap',
      'public' => true,
      'priority' => 30,
      'child_items' => [
         'category'           => array(
            'label'         => __( 'Categories', 'academy' ),
            'public' => true,
            'priority' => 30,
         ),
         'tag'           => array(
            'label'         => __( 'Tags', 'academy' ),
            'public' => true,
            'priority' => 30,
         ),
      ],
   );


   return $items;
}

Menu item keys:

  • label: The display name for the menu.
  • icon: Icon class for adding icon.
  • public: Visibility setting (true for public, false to hide).
  • priority: Determines menu order (lower priority appears first).

single menu:

$items['demo_item'] = array(
   'label' => __( 'Demo Item', 'academy' ),
   'icon'  => 'academy-icon academy-icon--Lesson',
   'public' => true,
   'priority' => 35,
);

Using this code, will add a menu with the label Demo Item in your frontend dashboard.

menu with submenus:

// item with submenu
$items['courses'] = array(
   'label' => __( 'Courses', 'academy' ),
   'icon'  => 'academy-icon academy-icon--course-cap',
   'public' => true,
   'priority' => 30,
   'child_items' => [
      'category'           => array(
         'label'         => __( 'Categories', 'academy' ),
         'public' => true,
         'priority' => 30,
      ),
      'tag'           => array(
         'label'         => __( 'Tags', 'academy' ),
         'public' => true,
         'priority' => 30,
      ),
   ],
);

The above code will add a menu with the label “Courses” with Submenu of “Categories” and “tags”.

Frontend Dashboard view:

Here’s a preview for your dashboard. You can see the available menu and submenu in the Courses section

Frontend Dashboard view

The courses and Demo Item menu were added to the frontend dashboard.

Removing a Menu #

To remove an existing menu, use the unset function to delete the corresponding array key:


if( isset( $items['profile'] ) ) {
   unset( $items['profile'] );
}

Before removal:

Profile menu is visible.

After removal:

Profile menu is no longer visible.

Organizing Menu Items #

To reorder menus, adjust the priority value. Lower values appear higher in the menu list.

// items without submenu
$items['demo_item'] = array(
   'label' => __( 'Demo Item', 'academy' ),
   'icon'  => 'academy-icon academy-icon--Lesson',
   'public' => true,
   'priority' => 30,
);
// item with submenu
$items['courses'] = array(
   'label' => __( 'Courses', 'academy' ),
   'icon'  => 'academy-icon academy-icon--course-cap',
   'public' => true,
   'priority' => 32,
   'child_items' => [
      'category'           => array(
         'label'         => __( 'Categories', 'academy' ),
         'public' => true,
         'priority' => 30,
      ),
      'tag'           => array(
         'label'         => __( 'Tags', 'academy' ),
         'public' => true,
         'priority' => 30,
      ),
   ],
);

Before organizing the menu item:

As you can see the “Demo Item” is below “All Lessons.”

After organizing the menu item:

You’ll see the “demo Item” before Courses.

Hiding a Menu #

To hide a menu, set its public attribute to false. Hidden menus will not appear in the frontend dashboard.

$items['courses'] = array(
   'label' => __( 'Courses', 'academy' ),
   'icon'  => 'academy-icon academy-icon--course-cap',
   'public' => false,
   'priority' => 32,
   'child_items' => [
      'category'           => array(
         'label'         => __( 'Categories', 'academy' ),
         'public' => true,
         'priority' => 30,
      ),
      'tag'           => array(
         'label'         => __( 'Tags', 'academy' ),
         'public' => true,
         'priority' => 30,
      ),
   ],
);

The menu Items are now hidden:

Here’s the code of array structure for menu:

$items['courses'] = array(
   'label' => __( 'Courses', 'academy' ),
   'icon'  => 'academy-icon academy-icon--course-cap',
   'public' => false,
   'priority' => 32,
   'child_items' => [
      'category'           => array(
         'label'         => __( 'Categories', 'academy' ),
         'public' => true,
         'priority' => 30,
      ),
      'tag'           => array(
         'label'         => __( 'Tags', 'academy' ),
         'public' => true,
         'priority' => 30,
      ),
   ],
);

Array keys:

  • menu_slug: Unique identifier for the menu.
  • label: Display name for the menu.
  • icon: Class for the icon.
  • public: Visibility option.
  • priority: Determines the menu’s display order.
  • child_items: Contains submenus with similar parameters.
What are your feelings
Updated on December 17, 2024