LLMS_Sessions::get_last_session( int $user_id = null )

Retrieve the last session object for the current user.

Parameters Parameters


(int) (Optional) WP_User ID of a student. Default null If not provided, or a falsy is provided, will fall back on the current user id.

Default value: null

Top ↑

Return Return


Top ↑

Source Source

File: includes/class-llms-sessions.php

	protected function get_last_session( $user_id = null ) {
		$user_id = $user_id ? $user_id : get_current_user_id();

		global $wpdb;
		return $wpdb->get_row(
				"SELECT *
			   FROM {$wpdb->prefix}lifterlms_events
			  WHERE actor_id = %d
			    AND object_type = 'session'
			    AND event_type = 'session'
			    AND event_action = 'start'
		   ORDER BY date DESC
			  LIMIT 1;",
		); // db call ok; no-cache ok.


Top ↑

Changelog Changelog

Version Description
4.5.0 Added optional $user_id parameter.
3.36.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.