LLMS_Student::get_certificates( string $orderby = 'updated_date', string $order = 'DESC', string $return = 'obj' )
Retrieve certificates that a user has earned
Description Description
Parameters Parameters
- $orderby
-
(string) (Optional) field to order the returned results by
Default value: 'updated_date'
- $order
-
(string) (Optional) ordering method for returned results (ASC or DESC)
Default value: 'DESC'
- $return
-
(string) (Optional) return type obj => array of objects from $wpdb->get_results certificates => array of LLMS_User_Certificate instances
Default value: 'obj'
Return Return
(array)
Source Source
File: includes/models/model.llms.student.php
public function get_certificates( $orderby = 'updated_date', $order = 'DESC', $return = 'obj' ) { $orderby = esc_sql( $orderby ); $order = esc_sql( $order ); global $wpdb; $query = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_value AS certificate_id, updated_date AS earned_date FROM {$wpdb->prefix}lifterlms_user_postmeta WHERE user_id = %d and meta_key = '_certificate_earned' ORDER BY $orderby $order", $this->get_id() ) ); if ( 'certificates' === $return ) { $ret = array(); foreach ( $query as $obj ) { $ret[] = new LLMS_User_Certificate( $obj->certificate_id ); } return $ret; } return $query; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
2.4.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: