apply_filters( 'learndash_settings_fields', array $setting_option_fields, string $settings_section_key )
Filters learndash setting fields.
Description #
Parameters #
- $setting_option_fields
-
(array) Associative array of Setting field details like name,type,label,value.
- $settings_section_key
-
(string) Used within the Settings API to uniquely identify this section.
Source #
File: includes/settings/settings-metaboxes/class-ld-settings-metabox-course-access-settings.php
Examples #
Note: Extended code example below not guaranteed, you may need to consult with a developer
<?php /** * Example usage for learndash_settings_fields filter. */ add_filter( 'learndash_settings_fields', function ( $setting_option_fields = array(), $settings_metabox_key = '' ) { // Check the metabox includes/settings/settings-metaboxes/class-ld-settings-metabox-course-access-settings.php line 23 where // settings_metabox_key is set. Each metabox or section has a unique settings key. if ( 'learndash-course-access-settings' === $settings_metabox_key ) { // Add field here. $post_id = get_the_ID(); $my_settings_value = get_post_meta( $post_id, 'my_meta_key', true ); if ( empty( $my_settings_value ) ) { $my_settings_value = 'default value'; } if ( ! isset( $setting_option_fields['my-custom-field'] ) ) { $setting_option_fields['my-custom'] = array( 'name' => 'my-custom-field', 'label' => sprintf( // translators: placeholder: Course. esc_html_x( '%s Field Label', 'placeholder: Course', 'learndash' ), learndash_get_custom_label( 'course' ) ), // Check the LD fields ligrary under incldues/settings/settings-fields/ 'type' => 'text', 'class' => '-medium', 'value' => $my_settings_value, 'default' => '', 'help_text' => sprintf( // translators: placeholder: course. esc_html_x( 'Some help text for %s.', 'placeholder: course.', 'learndash' ), learndash_get_custom_label_lower( 'course' ) ), ); } } // Always return $setting_option_fields return $setting_option_fields; }, 30, 2 ); // You have to save your own field. This is no longer handled by LD. This is on purpose. add_action( 'save_post', function( $post_id = 0, $post = null, $update = false ) { // All the metabox fields are in sections. Here we are grabbing the post data // within the settings key array where the added the custom field. if ( isset( $_POST['learndash-course-access-settings']['my-custom-field'] ) ) { $my_settings_value = esc_attr( $_POST['learndash-course-access-settings']['my-custom-field'] ); // Then update the post meta update_post_meta( $post_id, 'my_meta_key', $my_settings_value ); } }, 30, 3 );
Related #
@package #
Used By #
Used By | Description |
---|---|
includes/settings/settings-metaboxes/class-ld-settings-metabox-course-enrollment.php: LearnDash_Settings_Metabox_Course_Enrollment::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-course-completion-awards.php: LearnDash_Settings_Metabox_Course_Completion_Awards::load_settings_fields () |
Initialize the metabox settings fields. |
includes/reports/includes/class-ld-tinymce-courseinfo.php: LearnDash_Shortcodes_Section_ld_propanel::init_shortcodes_section_fields () | |
src/Core/Modules/AI/Virtual_Instructor/Settings/Page_Section.php: Page_Section::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-ai-integrations.php: LearnDash_Settings_Section_AI_Integrations::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-logs.php: LearnDash_Settings_Section_Logs::load_settings_fields () |
Initializes the settings fields. |
includes/settings/settings-sections/settings-sections-payments/class-ld-settings-section-razorpay.php: LearnDash_Settings_Section_Razorpay::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-payments-defaults.php: LearnDash_Settings_Section_Payments_Defaults::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/settings-sections-emails/class-ld-settings-section-emails-purchase-invoice.php: LearnDash_Settings_Section_Emails_Purchase_Invoice::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-coupon-settings.php: LearnDash_Settings_Metabox_Coupon_Settings::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-exam-display-content.php: LearnDash_Settings_Metabox_Exam_Display_Content::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/shortcodes-sections/learndash_user_status.php: LearnDash_Shortcodes_Section_learndash_user_status::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_infobar.php: LearnDash_Shortcodes_Section_ld_infobar::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_materials.php: LearnDash_Shortcodes_Section_ld_materials::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_navigation.php: LearnDash_Shortcodes_Section_ld_navigation::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/settings-sections/settings-sections-payments/class-ld-settings-section-stripe-connect.php: LearnDash_Settings_Section_Stripe_Connect::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/shortcodes-sections/ld_registration.php: LearnDash_Shortcodes_Section_ld_registration::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/settings-sections/class-ld-settings-section-registration-fields.php: LearnDash_Settings_Section_Registration_Fields::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-emails-sender-settings.php: LearnDash_Settings_Section_Emails_Sender_Settings::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/settings-sections-emails/class-ld-settings-section-emails-group-purchase-success.php: LearnDash_Settings_Section_Emails_Group_Purchase_Success::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/settings-sections-emails/class-ld-settings-section-emails-course-purchase-success.php: LearnDash_Settings_Section_Emails_Course_Purchase_Success::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/settings-sections-emails/class-ld-settings-section-emails-new-user-registration.php: LearnDash_Settings_Section_Emails_New_User_Registration::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-groups-management-display.php: LearnDash_Settings_Groups_Management_Display::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/shortcodes-sections/groupinfo.php: LearnDash_Shortcodes_Section_groupinfo::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_group_list.php: LearnDash_Shortcodes_Section_ld_group_list::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/settings-sections/class-ld-settings-section-groups-cpt.php: LearnDash_Settings_Groups_CPT::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-groups-group-leader-user.php: LearnDash_Settings_Section_Groups_Group_Leader_User::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-groups-membership.php: LearnDash_Settings_Groups_Membership::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-groups-taxonomies.php: LearnDash_Settings_Groups_Taxonomies::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-group-access-settings.php: LearnDash_Settings_Metabox_Group_Access_Settings::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-group-membership-post-settings.php: LearnDash_Settings_Metabox_Group_Membership_Post_Settings::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-group-display-content.php: LearnDash_Settings_Metabox_Group_Display_Content::load_settings_fields () |
Initialize the metabox settings fields. |
themes/ld30/includes/class-ld-settings-section-theme-ld30.php: LearnDash_Settings_Theme_LD30::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/shortcodes-sections/ld_course_info.php: LearnDash_Shortcodes_Section_ld_course_info::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/learndash_payment_buttons.php: LearnDash_Shortcodes_Section_learndash_payment_buttons::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/course_complete.php: LearnDash_Shortcodes_Section_course_complete::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/learndash_course_progress.php: LearnDash_Shortcodes_Section_learndash_course_progress::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/learndash_login.php: LearnDash_Shortcodes_Section_learndash_login::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/course_notstarted.php: LearnDash_Shortcodes_Section_course_notstarted::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/course_inprogress.php: LearnDash_Shortcodes_Section_course_inprogress::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_group.php: LearnDash_Shortcodes_Section_ld_group::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/usermeta.php: LearnDash_Shortcodes_Section_usermeta::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_quiz_list.php: LearnDash_Shortcodes_Section_ld_quiz_list::init_shortcodes_section_fields () |
Initialize shortcode fields. |
includes/settings/shortcodes-sections/ld_topic_list.php: LearnDash_Shortcodes_Section_ld_topic_list::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_course_list.php: LearnDash_Shortcodes_Section_ld_course_list::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_quiz_complete.php: LearnDash_Shortcodes_Section_ld_quiz_complete::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_course_resume.php: LearnDash_Shortcodes_Section_ld_course_resume::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/student.php: LearnDash_Shortcodes_Section_student::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_certificate.php: LearnDash_Shortcodes_Section_ld_certificate::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_course_expire_status.php: LearnDash_Shortcodes_Section_ld_course_expire_status::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/quizinfo.php: LearnDash_Shortcodes_Section_quizinfo::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_profile.php: LearnDash_Shortcodes_Section_ld_profile::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/courseinfo.php: LearnDash_Shortcodes_Section_courseinfo::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/user_groups.php: LearnDash_Shortcodes_Section_user_groups::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_lesson_list.php: LearnDash_Shortcodes_Section_ld_lesson_list::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/course_content.php: LearnDash_Shortcodes_Section_course_content::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/visitor.php: LearnDash_Shortcodes_Section_visitor::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_video.php: LearnDash_Shortcodes_Section_ld_video::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/shortcodes-sections/ld_user_course_points.php: LearnDash_Shortcodes_Section_ld_user_course_points::init_shortcodes_section_fields () |
Initialize the shortcode fields. |
includes/settings/settings-sections/class-ld-settings-section-quizzes-management-display.php: LearnDash_Settings_Quizzes_Management_Display::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-courses-themes.php: LearnDash_Settings_Courses_Themes::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-questions-cpt.php: LearnDash_Settings_Questions_CPT::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-general-per-page.php: LearnDash_Settings_Section_General_Per_Page::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-certificates-styles.php: LearnDash_Settings_Certificates_Styles::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-permalinks.php: LearnDash_Settings_Section_Permalinks::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-general-login-registration.php: LearnDash_Settings_Section_General_Login_Registration::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/settings-sections-payments/class-ld-settings-section-paypal.php: LearnDash_Settings_Section_PayPal::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-quizzes-cpt.php: LearnDash_Settings_Quizzes_CPT::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-lessons-taxonomies.php: LearnDash_Settings_Lessons_Taxonomies::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-custom-labels.php: LearnDash_Settings_Section_Custom_Labels::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-quizzes-email-settings.php: LearnDash_Settings_Quizzes_Email::load_settings_fields () |
Load the field settings fields |
includes/settings/settings-sections/class-ld-settings-section-topics-taxonomies.php: LearnDash_Settings_Topics_Taxonomies::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-certificates-cpt.php: LearnDash_Settings_Certificates_CPT::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-questions-management-display.php: LearnDash_Settings_Questions_Management_Display::load_settings_fields () |
Load the field settings fields |
includes/settings/settings-sections/class-ld-settings-section-general-admin-user.php: LearnDash_Settings_Section_General_Admin_User::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-courses-taxonomies.php: LearnDash_Settings_Courses_Taxonomies::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-courses-cpt.php: LearnDash_Settings_Courses_CPT::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-assignments-cpt.php: LearnDash_Settings_Assignments_CPT::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-quizzes-taxonomies.php: LearnDash_Settings_Quizzes_Taxonomies::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-lessons-cpt.php: LearnDash_Settings_Lessons_CPT::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-questions-taxonomies.php: LearnDash_Settings_Questions_Taxonomies::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-permalinks-taxonomies.php: LearnDash_Settings_Section_Permalinks_Taxonomies::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-general-rest-api.php: LearnDash_Settings_Section_General_REST_API::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-courses-management-display.php: LearnDash_Settings_Courses_Management_Display::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-sections/class-ld-settings-section-topics-cpt.php: LearnDash_Settings_Topics_CPT::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-topic-display-content.php: LearnDash_Settings_Metabox_Topic_Display_Content::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-quiz-display-content.php: LearnDash_Settings_Metabox_Quiz_Display_Content::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-course-access-settings.php: LearnDash_Settings_Metabox_Course_Access_Settings::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-quiz-access-settings.php: LearnDash_Settings_Metabox_Quiz_Access_Settings::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-lesson-access-settings.php: LearnDash_Settings_Metabox_Lesson_Access_Settings::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-quiz-progress-settings.php: LearnDash_Settings_Metabox_Quiz_Progress_Settings::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-quiz-results-display-content-options.php: LearnDash_Settings_Metabox_Quiz_Results_Options::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-course-display-content.php: LearnDash_Settings_Metabox_Course_Display_Content::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-lesson-display-content.php: LearnDash_Settings_Metabox_Lesson_Display_Content::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-topic-access-settings.php: LearnDash_Settings_Metabox_Topic_Access_Settings::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-course-navigation-settings.php: LearnDash_Settings_Metabox_Course_Navigation_Settings::load_settings_fields () |
Initialize the metabox settings fields. |
includes/settings/settings-metaboxes/class-ld-settings-metabox-quiz-admin-data-handling-settings.php: LearnDash_Settings_Metabox_Quiz_Admin_Data_Handling_Settings::load_settings_fields () |
Initialize the metabox settings fields. |