LLMS_Course::get_student_count( boolean $skip_cache = false )
Retrieve the number of enrolled students in the course
Description Description
The cached value is calculated in the LLMS_Processor_Course_Data
background processor.
If, for whatever reason, it’s not found, it will be calculated on demand and saved for later use.
Parameters Parameters
- $skip_cache
-
(boolean) (Optional) Default:
false
. Whether or not to bypass the cache. Iftrue
, bypasses the cache.Default value: false
Return Return
(int)
Source Source
File: includes/models/model.llms.course.php
$r = $q->posts; } else { $r = array(); foreach ( $q->posts as $p ) { $r[] = new LLMS_Section( $p ); } } return $r; } /** * Retrieve the number of enrolled students in the course * * The cached value is calculated in the `LLMS_Processor_Course_Data` background processor. * * If, for whatever reason, it's not found, it will be calculated on demand and saved for later use. * * @since 3.15.0 * @since 4.12.0 Use cached value where possible. * @since 6.0.0 Don't access `LLMS_Student_Query` properties directly. * * @param boolean $skip_cache Default: `false`. Whether or not to bypass the cache. If `true`, bypasses the cache. * @return int */ public function get_student_count( $skip_cache = false ) { $count = ! $skip_cache ? $this->get( 'enrolled_students' ) : false; /** * Query enrolled students when `$skip_cache=true` or when there's no stored meta data. * * The second condition is necessary to disambiguate between a cached `0` and a `0` that's * returned as the default value when the metadata doesn't exist. */ if ( false === $count || ! isset( $this->enrolled_students ) ) { $query = new LLMS_Student_Query( array( 'post_id' => $this->get( 'id' ), 'statuses' => array( 'enrolled' ), 'per_page' => 1,
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.0.0 | Don't access LLMS_Student_Query properties directly. |
4.12.0 | Use cached value where possible. |
3.15.0 | Introduced. |