Skip to main content

I have created a page for plugin. For that page i have added a checkbox meta field. The field is working fine. By By default, the checkbox field is unchecked. I mean at first to active the plugin, the checkbox field is unchecked. But But I need to make it check by default. I have tried a condition but not working at all. Codes areMy code is -:

https://gist.github.com/zmfoundation/a2a6d71d7d8435fb39c60bef5027c4f5

function ins_street_address_shortcode_callback(){
    $val = get_option('ins_street_address_shortcode');

    $checkval = "";

    if ($val == 'on'){
        $checkval = "checked";
    }

    printf("<input type='checkbox' name='ins_street_address_shortcode' %s />", $checkval);
}

I have created a page for plugin. For that page i have added a checkbox meta field. The field is working fine. By default, the checkbox field is unchecked. I mean at first to active the plugin, the checkbox field is unchecked. But I need to make it check by default. I have tried a condition but not working at all. Codes are -

https://gist.github.com/zmfoundation/a2a6d71d7d8435fb39c60bef5027c4f5

I have created a page for plugin. For that page i have added a checkbox meta field. The field is working fine. By default, the checkbox field is unchecked. I mean at first to active the plugin, the checkbox field is unchecked. But I need to make it check by default. I have tried a condition but not working at all. My code is :

function ins_street_address_shortcode_callback(){
    $val = get_option('ins_street_address_shortcode');

    $checkval = "";

    if ($val == 'on'){
        $checkval = "checked";
    }

    printf("<input type='checkbox' name='ins_street_address_shortcode' %s />", $checkval);
}
Source Link

Make the checkbox meta field checked by default

I have created a page for plugin. For that page i have added a checkbox meta field. The field is working fine. By default, the checkbox field is unchecked. I mean at first to active the plugin, the checkbox field is unchecked. But I need to make it check by default. I have tried a condition but not working at all. Codes are -

https://gist.github.com/zmfoundation/a2a6d71d7d8435fb39c60bef5027c4f5