• Resolved arijitsom99

    (@arijitsom99)


    Hello Team,

    below code is not working, i wanted to create custom field in option page of QSM plugin using “qsm_extra_setting_fields” hook

    Here is my code, please give me solution regarding below code

    function qsm_percentage_field(){
        global $mlwQuizMasterNext;
    
        $field_array = array(
    
            'id'      => 'passing_percentage',
            'label'   => __( 'Passing Percentage', 'quiz-master-next' ),
            'type'    => 'number',
            'default' => isset( get_option( 'qsm-quiz-settings' )['passing_percentage'] ) ? get_option( 'qsm-quiz-settings' )['passing_percentage'] : 70,
            'help'    => __( 'Set passing percentage', 'quiz-master-next' ),
        );
    $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
    
    }
    add_action('qsm_extra_setting_fields', 'qsm_percentage_field');

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @arijitsom99

    I need to discuss this with my development team. Hopefully, I will get back to you with the solution.

    Regards,
    Sumit

    Hi @arijitsom99

    Please use the below-given code and then check.

    function qsm_add_percentage_field(){
        global $mlwQuizMasterNext;
        $field_array = array(
            'id'         => 'passing_percentage',
            'label'      => __( 'Passing Percentage', 'quiz-master-next' ),
            'type'       => 'number',
            'default'    => isset( get_option( 'qsm-quiz-settings' )['passing_percentage'] ) ? get_option( 'qsm-quiz-settings' )['passing_percentage'] : 70,
            'help'       => __( 'Set passing percentage', 'quiz-master-next' ),
            'option_tab' => 'display',
        );
        $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' );
    }
    add_action('admin_init', 'qsm_add_percentage_field');

    Let me know if need more help on this issue.

    Regards,
    Sumit

    Thread Starter arijitsom99

    (@arijitsom99)

    Hello,
    Thank you for the reply.

    I tried your code with using the ‘admin_init’ hook but it is not working, I assume to add custom option in the Quiz we have to rely on the hook provided by Plugin which is ‘qsm_extra_setting_fields’. Do you have any update on this particular hook?

    Hi @arijitsom99

    The code is working properly please check below-given screencast link for your reference.

    Screencast

    Regards,
    Sumit

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘qsm_extra_setting_fields’ is closed to new replies.