LLMS_Integration_BBPress::restriction_checks_courses( array $results )

Check forum restrictions for course restrictions


Parameters Parameters

$results

(array) (Required) Array of restriction results.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/integrations/class.llms.integration.bbpress.php

	public function restriction_checks_courses( $results ) {

		$post_id = null;

		if ( bbp_is_forum( $results['content_id'] ) ) {

			$user_id = get_current_user_id();
			$courses = $this->get_forum_course_restrictions( $results['content_id'] );

			// No user and at least one course restriction, return the first.
			if ( $courses && ! $user_id ) {

				$post_id = $courses[0];

				// Courses and a user, find at least one enrollment.
			} elseif ( $courses && $user_id ) {

				foreach ( $courses as $course_id ) {
					// Not enrolled, use this for the restriction but dont break because we may find an enrollment later.
					if ( ! llms_is_user_enrolled( $user_id, $course_id ) ) {
						$post_id = $course_id;
						// Enrolled in one, reset the post id and break.
					} else {
						$post_id = null;
						break;
					}
				}
			}
		} elseif ( bbp_is_topic( $results['content_id'] ) ) {

			$results['content_id'] = bbp_get_topic_forum_id( $results['content_id'] );
			return $this->restriction_checks_courses( $results );

		}

		if ( $post_id ) {

			$results['restriction_id'] = $post_id;
			$results['reason']         = 'bbp_course_forum';

		}

		return $results;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.12.2 Unknown.
3.12.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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