learndash_override_course_auto_enroll

apply_filters( 'learndash_override_course_auto_enroll',  boolean $auto_enroll,  int $user_id )

Filters whether to auto enroll a user into a course or not.


Description #


Parameters #

$auto_enroll

(boolean) Whether to auto enroll user or not.

$user_id

(int) ID of the logged in user to check.


Source #

File: includes/course/ld-course-functions.php


Examples #

 <?php
/**
 * Example usage for learndash_override_course_auto_enroll filter.
 */
add_Filter( 'learndash_override_course_auto_enroll', 'learndash_override_course_auto_enroll_proc', 10, 2 );
function learndash_override_course_auto_enroll_proc( $auto_enroll, $user_id = 0 ) {
	if ( ! user_can( $user_id, 'administrator' ) ) {
		$auto_enroll = false;
	}

	return $auto_enroll;
}
 

Changelog #

Changelog
Version Description
2.3.0 Introduced.