Course Builder Custom Fields

Course Builder Custom Fields help to customize Course Builder by adding fields like:

  • input (text, number, radio, checkbox, date, ..)

  • textarea

  • select

  • repeater

Registering Custom Fields

Course, Lesson, and Quiz Custom Fields could be added using filters:

  • masterstudy_lms_course_custom_fields

  • masterstudy_lms_lesson_custom_fields

  • masterstudy_lms_quiz_custom_fields

Example:

function masterstudy_lms_custom_fields( $custom_fields ) {
	$quiz_custom_fields = array(
		array(
			'type'    => 'text',
			'name'    => 'my-text-field',
			'label'   => __( 'Text field', 'masterstudy-lms-learning-management-system' ),
		),
		...
	);

	return array_merge( $custom_fields, $quiz_custom_fields );
}

add_filter( 'masterstudy_lms_course_custom_fields', 'masterstudy_lms_custom_fields' );

How to filter custom fields before sending to Course Builder

Course Builder Custom Fields could be filtered before sending to Course Builder using masterstudy_lms_course_builder_custom_fields filter.

Example:

Processing Input Data

All input data will be automatically saved to post_meta. Additionally, data can be used with action:

Parameters:

  • $post_id int Course, Lesson, or Quiz Post ID.

  • $data array key => value array of Custom Fields

Example:

Outputting Custom Fields

All values from Custom Fields will be saved as Post Meta fields with corresponding keys. So they can be easily retrieved and displayed as post meta fields.

Example:

Custom Field Types

There are text, textarea, number, checkbox, radio and select types of custom fields. Let's look at examples of each.

Text

Textarea

TinyMCE Field

This custom field enables you to insert a text area with a powerful WYSIWYG text editor. Here is the code to insert:

Path to the required folder:

Number

Date

DatePicker field accepts and returns a value in Timestamp format. So the output of the date value is also different from other fields.

Example:

Time

Checkbox

Radio

Select

Repeater

You can use all Field Types inside a Repeater. For example:

Full Example

Here is an example of all custom field types with filters used:

Last updated

Was this helpful?