Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am getting the error illegal string offset when creating a checkbox in the admin.

my code look like this.

<input  type="checkbox"  id="slideThre" name="custom_settings[checked]" value="1" <?php checked(1, $custom_options['checked']);?>/>

There is no error when I check the box and save. The error appear when I uncheck the box and save.

What could be wrong?

thanks.

share|improve this question
2  
This is more a PHP question, debug your code. –  Wyck Jan 17 '13 at 0:31
add comment

1 Answer

up vote 2 down vote accepted

Checkboxes only send data when checked. When unchecked, there is no post (or get) data. You need to check if set using isset()

if (isset($_POST['custom_settings']['checked'])) { /* it was ticked */ }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.