1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. How to Order Courses on the BuddyBoss Profile Page

How to Order Courses on the BuddyBoss Profile Page

Introduction

By default, BuddyBoss does not provide an option to change the order of courses on the profile page. You can, however, sort the courses using a custom field like course_order and a small custom code snippet in your child theme. This guide explains how you can order courses on the BuddyBoss profile page.

Note: BuddyBoss does not provide a built-in setting for this. The steps below are a custom workaround.

Custom Workaround

Before proceeding, make sure you have a complete site backup.

  1. In your WordPress admin dashboard, go to Appearance > Theme Editor.
  2. Under Select theme to edit, choose your active child theme (preferably BuddyBoss Child Theme), then click Select.
  3. From the Theme Files list, click Theme Functions (functions.php).
  4. Paste the following code just before the closing PHP tag (?>):
function custom_buddyboss_my_courses_ordering( $args, $user_id ) {

    // Modify the query only for the "My Courses" section

    $args['meta_key'] = 'course_order'; // Custom field for the course order

    $args['orderby'] = 'meta_value_num'; // Sorting by the course order value (numeric)

    $args['order'] = 'ASC'; // Change to 'DESC' if you want descending order

    return $args;

}

add_filter( ‘ld_profile_query_args’, ‘custom_buddyboss_my_courses_ordering’, 10, 2 );

  1. Click Update File to save your changes.

Adding the Custom Field for Course Order

  1. Go to LearnDash LMS > Courses in your WordPress dashboard.
  2. Edit each course.
  3. Scroll down to the Custom Fields section.
  4. Add a custom field named course_order and assign it a value (e.g., 1 for the first course, 2 for the second, etc.).
  5. Save the course.

Note: If you don’t see the Custom Fields section, you may need to enable custom field support for LearnDash courses.

Troubleshooting and FAQs

Q: Courses are not sorted as expected, what should I check?
A: Make sure the course_order custom field exists for each course and has numeric values.

Q: Can I change the sorting to descending order?
A: Yes, change ‘ASC’ to ‘DESC’ in the code snippet.

Q: Will this affect other parts of the site?
A: No, this only affects the “My Courses” section in the user profile.

Q: Can I revert this change easily?
A: Yes, remove the code from functions.php and save.

Q: Who can I contact for further assistance?
A: Check the BuddyBoss Support Policy or consult a developer.

Was this article helpful?

Related Articles

Subscribe to Our Newsletter

Stay In Touch

Subscribe to our Newsletter, and we’ll send you the latest news from BuddyBoss

  • This field is hidden when viewing the form
  • This field is for validation purposes and should be left unchanged.

To speak to our Agency consultant, fill in the form found at our Contact Page.

  • Get Started

    Enter your name and email address to get started with your project...

  • This field is for validation purposes and should be left unchanged.