For course creators, insights into student progress can be an invaluable set of data. For sites using the Courses for Membership Add On default module, though, instructors don’t currently have a way to access this data. Until now.
This code recipe introduces a new column in the Courses admin page to display lesson progress and course completion across your members.
About the Courses for Membership Add On
PMPro’s Courses for Membership Add On serves two primary use cases:
- Use the default module to create courses with lessons and manage member access natively in Paid Memberships Pro, or
- Integrate with the most popular LMS plugins for WordPress, like LifterLMS.
The default module (which this code recipe supports) lets you organize course and lesson content, control access based on membership level, and track basic member lesson completion.
About the Code Recipe
When the Courses Add On is installed and activated, courses become a custom post type. Much like posts and pages, courses and lessons have their own WordPress list table. The default course list table shows:
- Course publish date
- Number of lessons within the course
- Membership level(s) with access
This code recipe introduces a new column to the Course and Lesson list tables. Here’s what the new columns will display:
- On the Lessons table, the new column shows the total number of members that marked the lesson complete.
- On the Courses table, the new column shows the total number of members who have completed the course (marked all lessons in the course complete).
Understanding Custom Post Types (CPTs) in WordPress
Custom Post Types (CPTs) are a powerful feature in WordPress that allow you to go beyond posts and pages to create different types of content for your website. They are essentially content types like posts and pages, but you can customize them to fit your site’s specific needs.
For example, in the context of the Courses for Membership Add On, we add two new CPTs to your WordPress site:
- Course
- Lesson
These new post types allow you to manage course content separately from your site’s posts and pages. Your theme can also style CPTs in a different way than the built-in posts and pages.
If you want to go deeper in your knowledge about WordPress Custom Post Types, check out the WordPress Developer Handbook: WordPress Developer Handbook on Post Types.
Leveraging Core WordPress Hooks: Managing Columns in Admin Tables
Action and filter hooks in WordPress allow developers to modify or add functionality to the WordPress core, plugins (like Paid Memberships Pro), and your theme.
In this recipe, we leverage two such hooks to add the custom columns to our course and lesson CPTs:
manage_post_type_posts_columns
: This hook allows you to add or remove columns from the list tables (like courses or lessons) in the WordPress admin area. This is how our code recipe introduces new columns to the Course and Lesson list tables. For more details, visit: manage_post_type_posts_columns Hook Reference.manage_post-post_type_posts_custom_column
: Once you have added new columns, this hook helps you to populate them with data. It’s how this recipe displays the total number of members who completed a lesson or a course in the new columns. Learn more at: manage_post-post_type_posts_custom_column Hook Reference.
The Code Recipe (PHP)
Adding the Recipe to Your Website
You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.
That’s it. Once the code is active in your site the new columns will immediately appear in the Course and Lesson screens in the WordPress admin.
Free Course: Membership Site Development—The Basics
Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.