LLMS_Table_Memberships::get_results( array $args = array() )
Execute a query to retrieve results from the table.
Parameters Parameters
- $args
-
(array) (Optional) Array of query args.
Default value: array()
Return Return
(void)
Source Source
File: includes/admin/reporting/tables/llms.table.memberships.php
public function get_results( $args = array() ) {
$this->title = __( 'Memberships', 'lifterlms' );
$args = $this->clean_args( $args );
if ( isset( $args['page'] ) ) {
$this->current_page = absint( $args['page'] );
}
$per = apply_filters( 'llms_reporting_' . $this->id . '_per_page', 25 );
$this->order = isset( $args['order'] ) ? $args['order'] : $this->order;
$this->orderby = isset( $args['orderby'] ) ? $args['orderby'] : $this->orderby;
$this->filter = isset( $args['filter'] ) ? $args['filter'] : $this->get_filter();
$this->filterby = isset( $args['filterby'] ) ? $args['filterby'] : $this->get_filterby();
$query_args = array(
'order' => $this->order,
'orderby' => $this->orderby,
'paged' => $this->current_page,
'post_status' => array( 'publish', 'private' ),
'post_type' => 'llms_membership',
'posts_per_page' => $per,
);
if ( 'any' !== $this->filter ) {
$serialized_id = serialize(
array(
'id' => absint( $this->filter ),
)
);
$serialized_id = str_replace( array( 'a:1:{', '}' ), '', $serialized_id );
$query_args['meta_query'] = array(
array(
'compare' => 'LIKE',
'key' => '_llms_instructors',
'value' => $serialized_id,
),
);
}
if ( isset( $args['search'] ) ) {
$query_args['s'] = sanitize_text_field( $args['search'] );
}
// If you can view others reports, make a regular query.
if ( current_user_can( 'view_others_lifterlms_reports' ) ) {
$query = new WP_Query( $query_args );
// User can only see their own reports, get a list of their students.
} elseif ( current_user_can( 'view_lifterlms_reports' ) ) {
$instructor = llms_get_instructor();
if ( ! $instructor ) {
return;
}
$query = $instructor->get_memberships( $query_args, 'query' );
} else {
return;
}
$this->max_pages = $query->max_num_pages;
if ( $this->max_pages > $this->current_page ) {
$this->is_last_page = false;
}
$this->tbody_data = $query->posts;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.32.0 | Introduced. |