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_idint
Course, Lesson, or Quiz Post ID.
$dataarraykey => 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:
Repeater field doesn't support Validation.
Full Example
Here is an example of all custom field types with filters used:
function masterstudy_lms_filter_custom_fields( $custom_fields, $post_id ) {
... // Here Custom Fields could be manipulated
return $custom_fields;
}
add_filter( 'masterstudy_lms_course_builder_custom_fields', 'masterstudy_lms_filter_custom_fields', 10, 2 );
do_action( 'masterstudy_lms_custom_fields_updated', int $post_id, array $data )
function masterstudy_lms_after_custom_fields_updated( $post_id, $data ) {
... // Here is your code
}
add_filter( 'masterstudy_lms_custom_fields_updated', 'masterstudy_lms_after_custom_fields_updated', 10, 2 );