Make check box Auto Checked

This topic contains 4 reply and 2 voices, and was last updated by Ryan 9 years, 11 months ago
Viewing 4 Posts - 1 through 4 (of 4 total)
Author Posts
December 4, 2014 at 3:01 am 31749
Ryan Hi, what is the best method to make this checkbox auto checked by default?
<div class="dokan-form-group">
        <label class="dokan-w4 dokan-control-label" for="_enable_reviews"><?php _e( 'Reviews', 'dokan' ); ?></label>
        <div class="dokan-w4 dokan-text-left">
            <?php $_enable_reviews = ( $post->comment_status == 'open' ) ? 'yes' : 'no'; ?>
            <?php dokan_post_input_box( $post->ID, '_enable_reviews', array('value' => $_enable_reviews, 'label' => __( 'Enable Reviews', 'dokan' ) ), 'checkbox' ); ?>
        </div>
    </div>
Thank you!
December 4, 2014 at 3:40 pm 31818
towhid towhid

Hello Ryan,

Yes, you can auto checked the checkbox. You need little bit modify the code. Let me explain this.

$_enable_reviews = ( $post->comment_status == ‘open’ ) ? ‘yes’ : ‘no’;

Above the code

If the Comment Status is open then it is ‘YES’ otherwise default is also ‘YES’. Try and let me know is it works.

Thank You 🙂

December 5, 2014 at 6:40 am 31875
Ryan Ryan

Perfect! Thank you sir 🙂

December 6, 2014 at 11:17 am 31922
towhid towhid

Hello Ryan,

Glad to know that the problem is solved. Would you please mark the topic as resolved.

Thank You 🙂

December 7, 2014 at 9:03 pm 31970
Ryan Ryan This reply has been marked as private.
Viewing 4 Posts - 1 through 4 (of 4 total)