<?php
function default_menu() {
<form action="options.php" method="post">
<?php settings_fields( 'sample_check' );?>
<input type="checkbox" name="sample" value="nofollow"/>
</form>
function reg_setting() {
register_setting('sample_check','???');
}
Hi all, I have struggled all day to store the check box values to the register setting. For the text box I used:
<input type="text" name="sam" value="<?php get_option('samip');?>" />
Also I register the values to the register setting like:
register_setting('sample_check','samip');
But I don’t know how to do this for a checkbox. If anyone could give me a suggestion for how to do this, that would be great.
Thanks,
vicky
3 Answers
The settings framework can’t detect data that is not posted, so either use a call to update_option or (what I sometimes do) use a yes/no radio button rather than a checkbox. With a radio button where the default value is 0 (no) and the alternative is 1 (yes), the user is setting the post value either way. You’re just making the user make an explicit choice.