Ajax::dozent_add_instructors()


Source

File: classes/Ajax.php

	public function dozent_add_instructors() {

		$course_id      = dozent_input_text( 'course_id' );
		$instructor_ids = dozent_input_array_field( 'instructors' );

		do_action( 'dozent_add_instructors_before', $instructor_ids, $course_id );

		if ( dozent_count( $instructor_ids ) ) {
			foreach ( $instructor_ids as $instructor_id ) {
				dozent_instructor_attach_course( $course_id, $instructor_id );
			}
		}

		do_action( 'dozent_add_instructors_after', $instructor_ids, $course_id );

		ob_start();
		include_once DOZENT_ABSPATH . 'views/metabox/part/instructors-list.php';
		$instructors_list = ob_get_clean();

		wp_send_json_success( [
			'message'               => dozent_notice( __( 'Instructor has been added', 'dozent' ), 'success', false ),
			'instructors_list_html' => $instructors_list,
		] );
	}