I'm working on adding a checkbox to my user registration page to opt-in to my e-mail list, and I'm not sure the proper way to have the checkbox ticked off by default. This is what I've got so far:
// Checkbox to join list
add_action( 'register_form', 'email_opt_in' );
function email_opt_in() { ?>
<p>
<label style="font-size:13px;">
<input type="checkbox" name="email_opt_in" id="email_opt_in" class="input" value="1" <?php checked( $_POST['email_opt_in'], 1 ); ?> tabindex="99" style="width:12px;padding:0;margin: 0 3px 0 0;font-size: 13px;" />
Join our famous e-mail list
</label>
</p>
<br/><?php
}
I'm using checked which works great, but I want the checkbox to be checked by default. Is adding checked="checked"
to input
the right thing to do, or is there a better way to do it?
Thanks in advance!