Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Engagement_Handler::check_post_enrollment( int $post_id, int $user_id )

Check that the specified user is enrolled in the given post.


Description Description

This check will return true when running against non-enrollable post types.


Top ↑

Parameters Parameters

$post_id

(int) (Required) WP_Post ID.

$user_id

(int) (Required) WP_User ID.


Top ↑

Return Return

(WP_Error|boolean) Returns true if the check passes, otherwise returns a WP_Error.


Top ↑

Source Source

File: includes/class-llms-engagement-handler.php

	private static function check_post_enrollment( $post_id, $user_id ) {

		$type  = get_post_type( $post_id );
		$types = llms_get_enrollable_status_check_post_types();

		// If the post type is an enrollable post type, check enrollment.
		if ( in_array( $type, $types, true ) && ! llms_is_user_enrolled( $user_id, $post_id ) ) {
			// Translators: %1$d = WP_User ID; %2$d = WP_Post ID.
			return new WP_Error( 'llms-engagement-check-post--enrollment', sprintf( __( 'User "%1$d" is not enrolled in "%2$d".', 'lifterlms' ), $user_id, $post_id ), compact( 'post_id', 'user_id' ) );
		}

		return true;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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