0

I have created a custom multi-select setting field on the lesson edit page in backend.

The code is as below

public function ld_custom_meta( $args ) {

    $cur_post_id =  $_GET['post'];
    $get_ld_lesson_val = get_post_meta( $cur_post_id, '_sfwd-lessons', true );

    $selected_val = $get_ld_lesson_val['sfwd-lessons__ld_media_products'];

    $_ld_media_products = get_media_products();

    $args['sfwd-lessons']['fields']['_ld_media_products'] = array(
        'name'              => __( 'Related Media Products', 'new-lms' ),
        'type'              => 'multiselect',
        'help_text'         => __( 'The selected products will be provided for free when a user gets access to this lesson via a subscription.', 'new-lms' ),
        'lazy_load'         => 1,
        'class'             => "ld_media_products select2",
        'value'             => $selected_val,
        'initial_options'   => $_ld_media_products,
    );
    return $args;
}

However, the value is not getting selected on the admin side.

enter image description here

Parthavi Patel
  • 739
  • 11
  • 28

0 Answers0