The Complete Guide to LifterLMS Filters in WordPress
Overview
WordPress uses a flexible event-driven architecture known as hooks, which allow independent plugins and custom code snippets to interact with WordPress core and third-party extensions without altering their underlying source code.
Hooks fall into two distinct categories: actions and filters.
- Actions execute custom code when a specific event occurs, such as a user logging in or publishing a new post.
- In contrast, filters in WordPress receive data, allow your custom code to modify or replace it, and then return the modified data to WordPress before it is displayed on the screen or stored in the database.
To attach your custom function to an existing filter hook in LifterLMS, you use the standard WordPress core function add_filter(). This function specifies:
- The name of the hook
- The name of your callback function
- The priority order in which your code runs
- The number of arguments your function accepts.
A filter function must always return a value. If your custom function receives a value, changes it, and forgets to return it, the receiving feature in LifterLMS will receive an empty value, which can cause unexpected display bugs or PHP errors.
LifterLMS provides hundreds of flexible hooks that let you adapt the platform to your specific business requirements. You can review the entire collection of available hooks in the official LifterLMS Code Reference.
This guide explains the available LifterLMS filters and hooks. If you need step-by-step instructions for implementing custom code, please refer to the official LifterLMS tutorial on how to add custom code to LifterLMS.
Video Demonstration
Watch this video tutorial, in which the LifterLMS engineering team explains the practical foundations of WordPress filters and demonstrates how to implement them to customize course behavior.
Reference of LifterLMS Filter Hooks
This section provides a detailed breakdown of available filters, their components, code examples, and implementation details to help you customize your LMS.
lifterlms_autoadvance
By default, LifterLMS automatically advances students to the next lesson immediately after they click the Mark Complete button. While this automated progression creates a seamless learning flow for standard video courses, it can disorient students when your lessons contain homework instructions, reflection worksheets, or resource links that students need to review after finishing their work.
Use the lifterlms_autoadvance filter to disable this automated progression. When you return false through this filter, the page reloads and keeps the student on the current completed lesson, displaying the completed status checkmark while allowing the student to review the content at their own pace.
Code Example
// disable auto-advance on lesson completion
add_filter( 'lifterlms_autoadvance', '__return_false' );
How This Code Works
This snippet uses the built-in WordPress core callback function __return_false. When LifterLMS checks the lifterlms_autoadvance filter, WordPress returns boolean false, which instructs the lesson controller to stay on the active lesson page rather than issuing a browser redirect to the subsequent lesson in the course outline.
llms_lesson_complete_redirect
When a student completes a lesson, you may want to direct them to a special destination rather than the next lesson in sequence. For example, you might want to send students to an external survey, a feedback submission form, a community discussion forum, or a custom celebratory landing page.
The llms_lesson_complete_redirect filter allows you to define a custom destination URL whenever a student completes a lesson.
Code Example
/**
* Redirect to a custom URL upon marking a lesson complete
* @param string $url default URL
* @return string
*/
function my_llms_lesson_complete_redirect( $url ) {
return 'http://mycustomurl.com';
}
add_filter( 'llms_lesson_complete_redirect', 'my_llms_lesson_complete_redirect', 10, 1 );
How This Code Works
The filter passes the default destination URL through the $url parameter. Your custom function intercepts this value and returns an absolute URL string pointing to your desired page. In the snippet above, replace http://mycustomurl.com with your specific URL.
You can combine this filter with conditional logic such as checking the current lesson ID using get_the_ID(). This allows you to redirect students to a feedback survey only after they finish the final lesson in a module, while letting intermediate lessons proceed normally.
llms_show_preview_excerpt
LifterLMS lesson tiles display a short excerpt or summary of the lesson underneath the lesson title. These tiles appear both on the main course syllabus page and in the previous- and next-lesson navigation controls on individual lesson pages.
Depending on your website design, displaying lesson excerpts in both locations can make navigation tiles look cluttered. The llms_show_preview_excerpt filter gives you complete control over whether these excerpts appear.
Option A: Disable Excerpts Everywhere
If you want a minimal, title-only layout across your entire LMS, use this snippet to turn off lesson preview excerpts everywhere:
// disables lesson short description in the lesson preview tiles
add_filter( 'llms_show_preview_excerpt', '__return_false' );
Option B: Show Excerpts on the Course Page Only
A popular design approach is to display rich lesson excerpts in the main course syllabus table so prospective students can understand the curriculum, while hiding them on the previous and next navigation tiles within lessons to keep the learning interface clean.
/**
* Display lesson excerpts on course syllabus but NOT on next / previous tiles on lesson pages
*/
function my_lesson_preview_function( $show ) {
if ( is_course() ) {
return true;
}
return false;
}
// disables lesson short description in the lesson preview tiles
add_filter( 'llms_show_preview_excerpt', 'my_lesson_preview_function' );
How This Code Works
In Option B, the callback function checks whether the LifterLMS conditional function is_course() returns true. If the visitor is viewing an individual course page, the function returns true to display the excerpt. If the visitor is on any other page, such as a lesson view, the function returns false, hiding the excerpt.
llms_achievement_loop_columns
Gamification is one of the most effective ways to motivate learners. When students earn achievement badges, LifterLMS displays them in a visual grid on the student dashboard and via achievement shortcodes.
By default, LifterLMS displays achievement badges in a four-column grid. You can adjust this grid layout using the llms_achievement_loop_columns filter.
Code Example
/**
* Modify the number of columns used when looping achievements on the student dashboard
* We have CSS in the core for anywhere from 1-5 columns
* if you need more than 5 columns you'll want to add additional custom css to accommodate:
* .lifterlms ul.llms-achievements-loop.loop-cols-6 li.llms-achievement-loop-item { width: 16.666%; }
* @param int $cols number of columns (default is 4)
* @return int
*/
function my_achievement_loop_columns( $cols ) {
return 5;
}
add_filter( 'llms_achievement_loop_columns', 'my_achievement_loop_columns', 999, 1 );
How This Code Works
The function receives the current column count as an integer through the $cols parameter and returns a new integer. LifterLMS core CSS includes native grid support for 1, 2, 3, 4, or 5 columns.
If you set the column count to 6, you will need to add a matching CSS rule to your theme so the badges divide evenly into six columns:
.lifterlms ul.llms-achievements-loop.loop-cols-6 li.llms-achievement-loop-item {
width: 16.666%;
}
lifterlms_checkout_buy_button_text
The text on your purchase button is one of the most important call-to-action elements on your website. By default, the LifterLMS checkout screen displays the phrase “Buy Now” on the final submission button.
Different business models require different wording. For example, a non-profit academy might prefer “Enroll Today”, a corporate training portal might require “Confirm Registration”, and an executive cohort might choose “Join Mastermind”. You can modify this text using the lifterlms_checkout_buy_button_text filter.
Code Example
/**
* Customize the text of the "Buy Now" button on the checkout screen
* @param string $text default text of the button
* @return string
*/
function my_llms_buy_button_text( $text ) {
return __( 'PURCHASE!', 'my-text-domain' );
}
add_filter( 'lifterlms_checkout_buy_button_text', 'my_llms_buy_button_text' );
How This Code Works
The filter passes the existing button string into the $text variable. Your function returns a customized string wrapped in the WordPress translation helper function __(), which ensures compatibility with multilingual plugins like WPML and Polylang.
lifterlms_currencies
LifterLMS provides built-in support for dozens of world currencies. However, if your business trades in a regional currency not present in the default dropdown list, you can register it using the lifterlms_currencies filter.
Code Example
function llms_add_currency( $currencies ) {
$code = 'ABC'; // currency code as per ISO currency code standards (http://www.iso.org/iso/home/standards/currency_codes.htm)
$name = __( 'Currency Name', 'my-text-domain' ); // name to be displayed for the currency
$currencies[$code] = $name;
return $currencies;
}
add_filter( 'lifterlms_currencies', 'llms_add_currency' );
How This Code Works
The filter receives an associative array of all registered currencies, where each key is an official three-letter ISO 4217 currency code, and each value is the human-readable currency name. The snippet adds your custom currency code and label to the array and returns the modified array.
Before adding a custom currency, confirm that your connected payment processor (such as Stripe, PayPal, or Authorize.Net) officially supports transactions in that currency. Adding a currency to the LifterLMS settings menu does not enable payment processing if the underlying gateway rejects the transaction.
lifterlms_recurring_price_html
When you create recurring access plans for subscriptions or payment plans, LifterLMS automatically generates a human-readable pricing description such as “$29.00 / month for 12 months”.
The lifterlms_recurring_price_html filter allows you to customize the text or HTML structure of this recurring pricing label to match your sales copy.
Code Example
/**
* Update the display of recurring payment information
* @param string $text HTML / Text to display the price
* @param obj $product Instance of the LLMS_Product
* @return string
*/
function llms_get_recurring_price_html( $text, $product ) {
return sprintf( __( 'Recurring Price: %s', 'my-text-domain' ), $text );
}
add_filter( 'lifterlms_recurring_price_html', 'llms_recurring_price_html', 10, 2 );
How This Code Works
The filter receives two parameters: the generated pricing HTML string ($text) and the product object instance ($product). Your custom function can inspect the product details, replace phrases, or append custom badges (such as “billed monthly”) before returning the final markup.
lifterlms_get_single_price_html
For one-time purchase access plans, LifterLMS constructs a pricing description that includes the phrase “single payment of” before the formatted currency amount (for example, “single payment of $199.00”).
Many site owners prefer a cleaner pricing display that shows only the price without redundant text. You can use the lifterlms_get_single_price_html filter to strip this phrase cleanly.
Code Example
/**
* Programmatically remove "Single Payment Of" from LifterLMS pricing screens
* @param string $text HTML / Text to display the price
* @param obj $product Instance of the LLMS_Product
* @return string
*/
function llms_get_single_price_html( $text, $product ) {
return str_replace( 'single payment of ', '', $text );
}
add_filter( 'lifterlms_get_single_price_html', 'llms_get_single_price_html', 10, 2 );
How This Code Works
The function uses PHP’s native str_replace() to locate the phrase “single payment of” inside the pricing HTML and replace it with an empty string, leaving a clean, professional price label.
llms_get_free_access_plan_pricing_text
When an access plan has a price of $0.00, LifterLMS displays the word “Free” across access plan cards and checkout forms.
While “Free” works well for open public courses, it can diminish perceived value on premium membership sites where bonus courses are bundled at no extra cost. In those cases, words like “Included”, “Complimentary”, or “Member Benefit” convey much higher value.
Code Example
/*
* Change the text displayed for free ($0.00) access plans
* @param string $text the default text ("Free")
* @return string
*/
function my_free_pricing_text( $text ) {
return __( 'INCLUDED', 'my-text-domain' ); // change text to whatever you want here
}
add_filter( 'llms_get_free_access_plan_pricing_text', 'my_free_pricing_text' );
How This Code Works
The filter passes the default string “Free” through the $text parameter. Your function replaces this value with your preferred term and returns the updated text.
llms_get_product_access_plan_limit
LifterLMS allows course creators and membership managers to attach multiple access plans to a single product. To keep the course builder interface fast and prevent accidental clutter, LifterLMS sets a default limit of 6 access plans per course or membership.
If your business model offers multiple regional currencies, group license options, installment arrangements, and lifetime tiers, you may reach this 6-plan limit quickly. Use the llms_get_product_access_plan_limit filter to raise or lower this ceiling.
Code Example
/**
* Change the maximum number of access plans which can be created for a single course / membership
* @param int $limit number of plans
* @return int
*/
function my_llms_get_product_access_plan_limit( $limit ) {
return 12;
}
add_filter( 'llms_get_product_access_plan_limit', 'my_llms_get_product_access_plan_limit' );
How This Code Works
The filter receives the current maximum limit as an integer. Your function returns a new integer, such as 12, allowing you to add up to 12 distinct access plans to any course or membership.
llms_has_free_checkout
To maximize student enrollments, LifterLMS includes a streamlined free checkout flow for access plans priced at $0.00. Under this default behavior, students can complete enrollment with a single click without filling out detailed billing address forms.
However, there are valid business reasons for requiring the full checkout screen, even on free courses. For instance, you may need to collect a phone number, collect a physical mailing address, or require students to check a mandatory terms of service agreement before they gain access.
Use the llms_has_free_checkout filter to disable the simplified free checkout and direct every student through the full checkout screen.
Code Example
add_filter( 'llms_has_free_checkout', '__return_false' );
How This Code Works
By returning false via WordPress core’s __return_false function, LifterLMS treats free access plans like standard checkout orders, displaying all registered checkout fields and compliance checkboxes. For an in-depth walkthrough of free enrollment behaviors, consult the official guide on checkout for free access plans.
llms_allow_subscription_cancellation
LifterLMS empowers students to manage their recurring payments through the student dashboard. By default, a student with an active recurring subscription can navigate to their order history and click a cancellation link to end their recurring payments.
However, certain organizations require students to contact support, speak with an advisor, or fulfill a minimum contract term (such as an annual installment agreement) before canceling. Use the llms_allow_subscription_cancellation filter to remove the self-cancellation option from the student dashboard.
Code Example
/**
* Prevents students from being able to self-cancel their recurring subscriptions on the student dashboard
*/
add_filter( 'llms_allow_subscription_cancellation', '__return_false' );
How This Code Works
The filter passes a boolean value indicating whether the cancellation action is allowed. By returning false through __return_false, LifterLMS hides the “Cancel” button on the student dashboard under My Orders.
This filter only affects the front-facing student dashboard. Site administrators can still cancel subscriptions at any time from the WordPress admin dashboard by navigating to LifterLMS > Orders.
llms_order_automatic_retry_rules
When a recurring subscription renewal fails (for example, due to an expired credit card or insufficient funds), LifterLMS executes an automated payment retry routine. This recovery sequence ensures that temporary banking hiccups do not immediately disrupt your recurring revenue.
The llms_order_automatic_retry_rules filter allows you to append custom retry steps or restructure the retry interval rules.
Code Example
/**
* Add a retry rule to the end of the default rules that waits 7 days and retries the recurring payment
* @param array $rules existing rules
* @return array
*/
function my_custom_retry_rules( $rules ) {
$rules[] = array(
'delay' => WEEK_IN_SECONDS,
'status' => 'on-hold',
'notifications' => true,
);
return $rules;
}
add_filter( 'llms_order_automatic_retry_rules', 'my_custom_retry_rules' );
How This Code Works
The filter receives an array of rule sets. Each rule contains:
delay: The time delay before the retry runs, expressed in seconds (such asWEEK_IN_SECONDS).status: The temporary order status assigned while waiting, such as'on-hold'.notifications: A boolean flag specifying whether to send an automated notification email to the customer informing them of the retry attempt.
For detailed information about automatic payment recovery schedules, review the official documentation on automatic retry of failed payments.
llms_order_status_can_resubscribe_from
When a student reviews their order history under the “My Orders” tab on the student dashboard, LifterLMS displays a “Resubscribe” action next to eligible orders. This button allows students to re-enroll in their subscription with updated payment details without restarting the checkout process.
By default, LifterLMS permits resubscription from three specific order statuses: llms-pending-cancel, llms-pending, and llms-on-hold. The llms_order_status_can_resubscribe_from filter allows you to expand or restrict this eligibility list.
Code Example
/**
* Customize which order statuses student can resubscribe from
* @param array $statuses array of order statuses
* default statuses: [ 'llms-pending-cancel', 'llms-pending', 'llms-on-hold' ]
* @return array
*/
function my_llms_order_status_can_resubscribe_from( $statuses ) {
unset( $statuses['llms-pending-cancel'] ); // this would make it so "Pending Cancellation" orders cannot be resubscribed from
$statuses[] = 'llms-failed'; // this allows "Failed" orders to be resubscribed to
return $statuses;
}
add_filter( 'llms_order_status_can_resubscribe_from', 'my_llms_order_status_can_resubscribe_from' );
How This Code Works
The filter passes the array of eligible status slugs into the $statuses parameter. In this example, the code removes llms-pending-cancel so that students who scheduled a cancellation cannot accidentally renew, and adds llms-failed so that students whose recurring payments have permanently failed can quickly resubscribe with a new card.
lifterlms_sitewide_restriction_bypass_ids
LifterLMS includes a powerful feature called Sitewide Membership Restriction. When enabled under LifterLMS > Settings > Memberships, any visitor who is not an active member is blocked from viewing content across the site.
While this feature works well for private membership networks, you must still keep essential public pages accessible, such as your Privacy Policy, Terms of Service, Public Contact form, or Sales Landing pages.
Use the lifterlms_sitewide_restriction_bypass_ids filter to whitelist specific WordPress pages or post IDs from sitewide restrictions.
Code Example
/**
* Add additional pages to the list of pages shown to non-enrolled visitors when sitewide membership restrictions are in effect
* @param array $ids WP Post IDs
* @return array
*/
function my_lifterlms_sitewide_restriction_bypass_ids( $ids ) {
// add the WP Post IDs of posts which can be accessed without being an enrolled member here
$custom_ids = array( 123, 456, 789 );
return array_merge( $ids, $custom_ids );
}
add_filter( 'lifterlms_sitewide_restriction_bypass_ids', 'my_lifterlms_sitewide_restriction_bypass_ids', 10, 1 );
How This Code Works
The filter passes the existing array of whitelisted post IDs into the $ids parameter. The snippet defines an array of custom WordPress post IDs (for example, array(123, 456, 789)) and merges them using PHP’s array_merge(), ensuring that non-members can visit those specific pages without encountering the restriction barrier.
llms_is_post_restricted_by_membership_skip_post_types
LifterLMS membership restrictions allow you to protect content based on membership enrollment. To maintain predictable hierarchy rules, LifterLMS automatically skips checking membership restrictions on core learning post types:
courselessonllms_quizllms_membershipllms_questionllms_certificatellms_my_certificate
Because lessons normally inherit their access restrictions directly from their parent course, individual lessons are bypassed by default. You can use the llms_is_post_restricted_by_membership_skip_post_types filter to alter this behavior.
Example 1: Remove Lessons from the Bypass List to Restrict Lessons Directly
If you want to apply membership restrictions directly to individual lessons (rather than exclusively at the course level), remove the lesson from the bypass array:
/**
* Remove a post type from the list of post types LifterLMS will NOT check for membership restrictions
* @param array $post_types array of post type names
* @return array
*/
function my_allow_lessons_restrictions( $post_types ) {
// the following post types are automatically bypassed
// during membership restriction checks
// course
// lesson
// llms_quiz
// llms_membership
// llms_question
// llms_certificate
// llms_my_certificate
// this will remove lessons from the list so that lessons can be restricted
$i = array_search( 'lesson', $post_types );
if ( false !== $i ) {
unset( $post_types[ $i ] );
}
return $post_types;
}
add_filter( 'llms_is_post_restricted_by_membership_skip_post_types', 'my_allow_lessons_restrictions' );
Example 2: Add a Custom Post Type to the Bypass List
If you run custom post types (such as custom documentation, podcast episodes, or downloads) that you never want blocked by membership rules, add them to the bypass array:
/**
* Add a post type to the list of post types LifterLMS will NOT check for membership restrictions.
* @param array $post_types array of post type names
* @return array
*/
function my_allow_lessons_restrictions( $post_types ) {
array_push( $post_types, 'my_custom_post_type' );
return $post_types;
}
add_filter( 'llms_is_post_restricted_by_membership_skip_post_types', 'my_allow_lessons_restrictions' );
lifterlms_registration_redirect
First impressions matter. When new students create an account on your LifterLMS site, the default flow redirects them to the student dashboard or the checkout page they started on.
Use the lifterlms_registration_redirect filter to guide new students to a dedicated onboarding destination, such as a “Welcome to the Academy” orientation page or a survey where they configure their learning preferences.
Code Example
/**
* Redirect to a custom page on your site during LifterLMS Registrations
* @param string $url default URL
* @return string
*/
function my_lifterlms_reg_redirect( $url ) {
return untrailingslashit( get_site_url() ) . '/my-custom-redirect-page';
}
add_filter( 'lifterlms_registration_redirect', 'my_lifterlms_reg_redirect' );
How This Code Works
The filter passes the default redirect URL string. Your function replaces this string with your target URL. In this example, get_site_url() is combined with a custom path slug to ensure the redirect works across development, staging, and production domains.
llms_student_dashboard_default_tab
When an enrolled student logs in and visits the LifterLMS student dashboard page, the dashboard opens to the main overview tab by default.
Many course creators prefer taking students directly to their active courses without requiring an extra click. You can change the initial landing tab using the llms_student_dashboard_default_tab filter.
Code Example
/**
* Customize the default tab displayed when a student visits the student dashboard
*/
function my_custom_student_dashboard_tab( $tab ) {
return 'view-courses';
}
add_filter( 'llms_student_dashboard_default_tab', 'my_custom_student_dashboard_tab' );
How This Code Works
The function receives the default tab slug and returns a new tab slug, such as 'view-courses'. The next time a student opens the dashboard, the “My Courses” view displays immediately.
llms_get_student_dashboard_tabs
The LifterLMS student dashboard features a tabbed navigation menu that organizes student resources: courses, achievements, certificates, notifications, account details, orders, and sign-out.
The llms_get_student_dashboard_tabs filter allows you to remove tabs you no longer need, add links to external pages, or create fully custom dashboard endpoints with unique content.
Example 1: Remove Unwanted Dashboard Tabs
If your academy does not use certain dashboard features, such as vouchers or order history, you can hide their tabs by removing the relevant entries from the tabs array:
/**
* Remove tabs from the LifterLMS Student dashboard
* @param array $tabs registered tabs
* @return array
*/
function my_remove_dashboard_tabs( $tabs ) {
// unset( $tabs['view-courses'] );
// unset( $tabs['view-achievements'] );
// unset( $tabs['notifications'] );
// unset( $tabs['edit-account'] );
// unset( $tabs['redeem-voucher'] );
// unset( $tabs['orders'] );
// unset( $tabs['signout'] );
return $tabs;
}
add_filter( 'llms_get_student_dashboard_tabs', 'my_remove_dashboard_tabs' );
Example 2: Add Custom Tabs and Dedicated Endpoints
You can also add custom tabs. This snippet demonstrates two approaches: adding a direct URL link tab and creating a fully integrated dashboard endpoint with custom HTML content.
/**
* Add custom dashboard tabs / urls to the dashboard navigation
* @param array $tabs existing tabs
* @return array
*/
function my_custom_dashboard_tabs( $tabs ) {
// save the signout tab
$signout = $tabs['signout'];
// remove the signout tab
unset( $tabs['signout'] );
/**
* Add custom Tabs below
*/
// Basic Custom tab with URL (eg: link to a WordPress page)
$tabs['my-tab'] = array(
'title' => __( 'My Tab Title', 'my-text-domain' ),
'url' => 'http://mydomain.com/path/to/url',
);
// Advanced Custom tab with content displayed on the Dashboard as an endpoint
// NOTE: you'll need to FLUSH PERMALINKS after adding a custom endpoint, if you don't the endpoint will 404!
// how to flush permalinks: https://lifterlms.com/docs/how-to-flush-wordpress-rewrite-rules-or-permalinks/
$tabs['my-endpoint'] = array(
'content' => 'my_custom_endpoint_content', // this should be a callable function that outputs your content
'endpoint' => __( 'my-endpoint', 'my-text-domain' ), // endpoint slug (eg: http://mysite.com/my-courses/my-endpoint)
'nav_item' => true, // will add the endpoint to LifterLMS section on WP menu admin pages for use on WP nav menus
'title' => __( 'My Endpoint Title', 'my-text-domain' ),
);
// restore the signout tab
$tabs['signout'] = $signout;
return $tabs;
}
add_filter( 'llms_get_student_dashboard_tabs', 'my_custom_dashboard_tabs', 10, 1 );
/**
* Outputs HTML content for a custom endpoint
* @return void
*/
function my_custom_endpoint_content() {
echo '<p>This is my endpoint content</p>';
}
Mandatory Step: Flush Permalinks After Adding Endpoints
Whenever you register a custom dashboard endpoint in LifterLMS, WordPress needs to update its internal rewrite rules. If you skip this step, clicking your new dashboard tab will produce a 404 “Page Not Found” error.
- In your WordPress admin dashboard, navigate to Settings > Permalinks.
- Scroll down to the bottom of the page without changing any settings.
- Click Save Changes.
- Test your new student dashboard tab on the front end to verify that the custom content displays correctly.
For more details on resolving rewrite issues, consult the guide on how to flush WordPress rewrite rules or permalinks.
llms_dashboard_courses_per_page
On the student dashboard, when a student clicks “View All Courses”, LifterLMS paginates their course list, showing 10 courses per page by default.
If your students are enrolled in dozens of short courses or have access to an extensive course catalog, displaying 25 or 50 courses per page makes it easier to browse their courses. Use the llms_dashboard_courses_per_page filter to customize this limit.
Code Example
/**
* Customize the number of courses displayed on each page of the "View Courses" endpoint on the LifterLMS Student Dashboard
* @param int $count default number of courses (10)
* @return int
*/
function my_custom_llms_dashboard_recent_courses_count( $count ) {
return 25;
}
add_filter( 'llms_dashboard_courses_per_page', 'my_custom_llms_dashboard_recent_courses_count' );
How This Code Works
The filter passes the default course count integer (10) through the $count parameter. Your custom function returns the new number of courses to display before pagination links appear.
llms_notifications_settings
LifterLMS includes a real-time on-screen notification system that alerts students when they earn achievements, complete lessons, or receive instructor feedback.
To deliver timely updates, LifterLMS sends background AJAX heartbeat requests from the student’s browser to the WordPress server. The llms_notifications_settings filter lets you fine-tune the heartbeat interval to conserve server resources on high-traffic websites.
Code Example
/**
* Filter to customize settings associated with LifterLMS Basic Notifications.
*
* https://lifterlms.com/docs/lifterlms-filters/#llms_notifications_settings
*
* 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 documentation for step-by-step directions on either method.
* https://lifterlms.com/docs/adding-custom-code/
*/
function my_llms_notifications_settings( $settings ) {
$settings['heartbeat_interval'] = 60000;
return $settings;
}
add_filter( 'llms_notifications_settings', 'my_llms_notifications_settings', 10, 1 );
How This Code Works
The $settings array contains the heartbeat_interval value specified in milliseconds. In the snippet above, setting the interval to 60000 instructs the browser to poll for new notifications every 60 seconds (instead of the default 30-second interval), reducing background database requests by half.
llms_email_css
LifterLMS automatically dispatches transactional emails for account creation, course enrollment, lesson completion, and password resets. Keeping these emails consistent with your brand colors reinforces student trust and visual professionalism.
Instead of copying and overriding PHP email template files, you can style your emails directly using the llms_email_css filter.
Code Example
add_filter( 'llms_email_css', 'my_llms_email_branding' );
function my_llms_email_branding( $css ) {
// these are all the defineable rules with their defaults
// uncomment and customize whichever you wish to customize
// not a dev? Confused? I'll be adding branding options to LifterLMS Labs in conjunction with the public release of LifterLMS 3.8
// $css['background-color'] = '#f6f6f6';
// $css['border-radius'] = '3px';
// $css['button-background-color'] = '#2295ff';
// $css['button-font-color'] = '#ffffff';
// $css['divider-color'] = '#cecece';
// $css['font-color'] = '#222222';
// $css['font-family'] = 'sans-serif';
// $css['font-size'] = '15px';
// $css['font-size-small'] = '13px';
// $css['heading-background-color'] = '#2295ff';
// $css['heading-font-color'] = '#ffffff';
// $css['main-color'] = '#2295ff';
// $css['max-width'] = '580px';
return $css;
}
How This Code Works
The filter receives an associative array of CSS rules that LifterLMS compiles into inline styles for each outgoing HTML email. You can uncomment and modify whichever properties you wish to adjust:
background-color: The canvas color behind the main email card.button-background-color: The background color of call-to-action buttons.button-font-color: The text color inside buttons.font-familyandfont-size: Typography rules for body copy.heading-background-color: The banner color behind email headers.main-color: Accent color applied to headings and links.max-width: The maximum container width for desktop email clients.
llms_gradebook_students_per_page
Under LifterLMS > Reporting > Students, administrators and instructors can review student enrollment records, course progress percentages, and grade calculations. By default, this table lists 20 students per page.
Use the llms_gradebook_students_per_page filter to display more students at once for faster grading and administrative reviews.
Code Example
/**
* Customize the number of students per page on the admin reporting table
* @param int $num default (20)
* @return int
*/
function my_results_per_page( $num ) {
return 50;
}
add_filter( 'llms_gradebook_students_per_page', 'my_results_per_page' );
Server Memory and Timeout Considerations
Each student row in the gradebook calculates overall progress, lesson counts, and quiz scores. Setting this number too high (e.g., 250 or 500) can exhaust your server’s PHP memory allocation or trigger timeout errors. Setting this value to 50 provides a practical balance between speed and convenience.
llms_gradebook_student-courses_per_page
When you drill down into a specific student’s profile under LifterLMS > Reporting > Students to see all courses the student is enrolled in, LifterLMS displays 20 courses per page.
Use the llms_gradebook_student-courses_per_page filter to modify how many course rows appear in this detailed student view.
Code Example
/**
* Customize the number of courses per page on the admin reporting table for a student's course list
* @param int $num default (20)
* @return int
*/
function my_results_per_page( $num ) {
return 50;
}
add_filter( 'llms_gradebook_student-courses_per_page', 'my_results_per_page' );
How This Code Works
The filter passes the default integer (20) into the $num parameter. Your custom function returns your preferred row count, such as 50.
Admin Panel User Custom Fields
In many educational institutions, student records require more than just a name and an email address. You may need to store a student ID number, a regional certification code, a company affiliation, or a license renewal date.
LifterLMS provides a dedicated system located in includes/admin/class.llms.admin.user.custom.fields.php that allows developers to add, display, validate, and save custom metadata directly on the WordPress admin user profile screen (located at Users > All Users > Edit User).
This architecture uses four coordinated filter hooks to manage the complete lifecycle of custom user fields.
1. lifterlms_get_user_custom_fields
Use this filter to declare and render new input fields on the user profile screen in the WordPress admin panel.
Code Example
/**
* Add a custom field to the user's profile on the WP admin panel
* @param array $fields associative array of field data
* @return array
*/
function my_custom_user_fields( $fields ) {
$fields['llms_custom_field_id'] = array( // array key *should* the value you want to store in the WP usermeta table
'description' => 'A short description of this field',
'label' => __( 'My Custom Field Label', 'my-text-domain' ),
'required' => false, // if you want this field to be required, switch to "true"
'type' => 'text', // accepts any valid HTML5 input type, note that we don't have support for textareas or select elements!
);
return $fields;
}
add_filter( 'lifterlms_get_user_custom_fields', 'my_custom_user_fields', 10, 1 );
How This Code Works
The filter receives an associative array of custom fields. The array key (in this case, 'llms_custom_field_id') serves as the meta key stored in the WordPress usermeta database table. You define an array containing the field configuration:
label: The label displayed next to the input field on the user profile screen.description: Helpful guidance text displayed directly below the input field.type: The HTML5 input type (such as'text','email','number', or'tel'). Note that select dropdowns and textareas are not supported by this specific handler.required: A boolean flag indicating whether the field must be completed before saving.
2. lifterlms_get_user_custom_field_value_{$field_id}
This dynamic filter allows you to format or transform the stored metadata value before LifterLMS renders it inside the admin form input.
Code Example
/**
* Override the default value of a custom field retrieved from the usermeta table
*
* note that this filter isn't necessary but *can* be used if you don't simply
* want to retrieve the value of the field from the usermeta table
*
* @param mixed $value value from the usermeta table
* @param obj $user Instance of WP_User for whom data is being retrieved
* @param string $field_id id / name of the field
* @return mixed
*/
function my_custom_field_value( $value, $user, $field_id ) {
// do something with the field value, for example replace underscores with spaces because why not?
$value = str_replace( '_', ' ', $value );
return $value;
}
add_filter( 'lifterlms_get_user_custom_field_value_my_custom_field_id', 'my_custom_field_value', 10, 3 ); // "my_custom_field_id" should be replaced with your field's id!
How This Code Works
This hook is dynamic, meaning you replace {$field_id} in the filter name with your actual field identifier (for example, lifterlms_get_user_custom_field_value_my_custom_field_id). The function receives three arguments: the raw value retrieved from the database, the WP_User instance, and the field identifier string. You can format dates, replace underscores with spaces, or apply custom display masks before outputting the value.
3. lifterlms_validate_custom_user_field_{$field_id}
Before custom user data is written to the database, you must ensure it satisfies your data validation requirements. Use this dynamic filter to validate input and return user-friendly error messages if the data is invalid.
Code Example
/**
* Run custom validation against the field
* If filter function returns a truthy, validation will stop, fields will not be saved,
* and an error message will be displayed on screen
*
* This should return false or a string which will be used as the error message
*
* If false is returned, the field has "passed" validation (eg no errors)
*
* @param mixed $error false or error message string
* @param string $field_id field id or name
* @param obj $user Instance of WP_User
* @return mixed
*/
function my_custom_field_validation( $error, $field_id, $user ) {
// for example, lets make sure the field is numeric
if ( ! is_numeric( $_POST[$field_id] ) ) {
$error = __( 'ERROR: The value of "My Custom Field" must be numeric!', 'my-text-doamin' );
}
return $error;
}
add_filter( 'lifterlms_validate_custom_user_field_my_custom_field_id', 'my_custom_field_validation', 10, 3 );
How This Code Works
The function receives three parameters: the current error state ($error, which begins as boolean false), the field identifier ($field_id), and the target WP_User object.
If the submitted data passes your validation rules, the function returns false. If the input fails validation (for example, if a student ID contains non-numeric characters), your function returns an error message string. When a string is returned, LifterLMS halts the save process and displays your error message in an administrative notice at the top of the screen.
4. lifterlms_save_custom_user_field_{$field_id}
Once input passes validation, this dynamic filter allows you to sanitize or format the value immediately before LifterLMS writes it to the WordPress usermeta database table.
Code Example
/**
* Customize the value stored in the database before the field data is saved
*
* This runs after validation so no need to re-validate here
*
* @param mixed $value user submitted value
* @param obj $user WP_User instance
* @param string $field_id name / id of the field
* @return mixed
*/
function my_custom_field_save( $value, $user, $field_id ) {
// for example ensure remove protocol prefixes from the beginning of a web address field
$value = str_replace( array( 'https://', 'http://' ), '', $value );
return $value;
}
add_filter( 'lifterlms_save_custom_user_field_my_custom_field_id', 'my_custom_field_save', 10, 3 );
How This Code Works
The function receives the submitted value, the WP_User object, and the field identifier. Because this filter executes only after all validation checks have passed, you can safely sanitize the data. In the example above, the function strips protocol prefixes like http:// and https:// from a website address before storing it.
Troubleshooting and Safe Testing Checklist
Working with custom PHP code requires careful procedures. A single missing semicolon or mismatched parenthesis can cause PHP syntax errors. Follow this testing checklist whenever you add or modify code on your website.
1. Always Test on a Staging Environment First
Never test new code snippets directly on your live production site. Set up a staging copy of your website using your hosting provider’s staging tool or a staging plugin. Verify every change thoroughly on staging before applying it to your production website.
2. How to Recover from Syntax Errors (The White Screen)
If your website displays a critical error or white screen after activating a snippet, follow these recovery steps:
- If you use a code snippets plugin, WordPress often catches the fatal error automatically and deactivates the problematic snippet.
- Check your administrative email inbox for an automated “WordPress Recovery Mode” link sent by WordPress core. Clicking that link allows you to log into your dashboard in safe mode and disable the snippet.
- If you edited your child theme’s functions.php file, connect to your server using SFTP or your hosting File Manager.
- Open wp-content/themes/your-child-theme/functions.php and remove or comment out the snippet you just added.
- Save the file. If the snippet caused the error, removing it should restore access to your site.
3. Flushing WordPress Rewrite Rules and Permalinks
If you register custom student dashboard endpoints using the llms_get_student_dashboard_tabs filter and experience 404 errors when clicking the new tab, your WordPress rewrite rules need to be flushed:
- Log in to your WordPress admin dashboard.
- Navigate to Settings > Permalinks.
- Scroll down to the bottom of the screen without changing any settings.
- Click Save Changes.
4. Verifying Filter Priority and Argument Counts
When registering filters using add_filter(), pay close attention to the third and fourth arguments:
- Priority (default is 10): Specifies the execution order. If your custom snippet needs to override another plugin’s filter, pass a higher priority number such as 20 or 99.
- Accepted Arguments (default is 1): Specifies how many parameters your callback function expects. If your function accepts two parameters (such as
$textand$productin pricing filters), you must specify2as the fourth argument, or PHP will throw an argument count error.
Summary and Next Steps
By using LifterLMS filters, you can tailor your course delivery, pricing architecture, and student experience with precision while maintaining a clean, update-proof codebase. Bookmark this guide as your ongoing development reference whenever you need to customize your WordPress Learning Management System.


