public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Action called when a new user is created in WordPress. Used to check if we need to
 * automatically add access for this user to access a training course.
 *
 * @since 1.0.0
 *
 * @param integer $user_id The ID of the user that's just been added.
 */
Action called when a new user is created in WordPress. Used to check if we need to
automatically add access for this user to access a training course.



@param integer $user_id The ID of the user that's just been added.
Action called when a new user is created in WordPress . Used to check if we need to automatically add access for this user to access a training course . @param integer $user_id The ID of the user that ' s just been added .
function WPCW_actions_users_newUserCreated( $user_id ) {
	$courses = array();
	if ( isset( $_POST['course_id'] ) ) {
		foreach ( $_POST['course_id'] as $key => $value ) {
			$courses[] = $value;
		}
	} else {
		$ignoreOnNewUser = apply_filters( 'wpcw_extensions_ignore_new_user', false );
		if ( $ignoreOnNewUser ) {
			return;
		}
	}
	global $wpdb, $wpcwdb;
	$wpdb->show_errors();
	$automatic_courses = $wpdb->get_col( "SELECT * FROM $wpcwdb->courses WHERE course_opt_user_access = 'default_show'" );
	if ( $automatic_courses ) {
		foreach ( $automatic_courses as $automatic_course ) {
			if ( apply_filters( 'wpcw_course_automatic_enrollment_disable', false, $automatic_course ) ) {
				continue;
			}
			$courses[] = $automatic_course;
		}
	}
	if ( ! $courses || count( $courses ) < 1 ) {
		return;
	}
	WPCW_courses_syncUserAccess( $user_id, $courses, 'sync' );
}
function WPCW_actions_users_newUserCreated ( $ user_id ) { $ courses = array ( ) ; if ( isset ( $ _POST [ 'course_id' ] ) ) { foreach ( $ _POST [ 'course_id' ] as $ key => $ value ) { $ courses [ ] = $ value ; } } else { $ ignoreOnNewUser = apply_filters ( 'wpcw_extensions_ignore_new_user' , false ) ; if ( $ ignoreOnNewUser ) { return ; } } global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; $ automatic_courses = $ wpdb -> get_col ( " SELECT * FROM  $ wpcwdb -> courses  WHERE course_opt_user_access = 'default_show' " ) ; if ( $ automatic_courses ) { foreach ( $ automatic_courses as $ automatic_course ) { if ( apply_filters ( 'wpcw_course_automatic_enrollment_disable' , false , $ automatic_course ) ) { continue ; } $ courses [ ] = $ automatic_course ; } } if ( ! $ courses || count ( $ courses ) < 1 ) { return ; } WPCW_courses_syncUserAccess ( $ user_id , $ courses , 'sync' ) ; }
Action called when a new user is created in WordPress.
Action called when a new user is created in WordPress .
// Checks for course ID on post which will enroll student into specified course. /**
		 * Filter: Extensions Ignore New User.
		 *
		 * See if an extension is taking over the checking
		 * of access control. If a function is defined to
		 * return true, then this section of code is ignored.
		 *
		 * @since 4.3.0
		 *
		 * @param bool True to ignore user. Default is false
		 *
		 * @return bool The boolean value to ignore a new user.
		 */ // Get a list of all courses that want users added automatically. /**
			 * Filter: Disable Course Automatic Enrollment.
			 *
			 * @since 4.3.0
			 *
			 * @param bool True to disabled, false to enable. Default is false.
			 * @param int $automatic_course The automatic course id.
			 *
			 * @return bool The boolean value to disable automatic enrollment for a certain course.
			 */ // None found // Add access for this user to all courses we're associated with.