Hello and thanks for such an amazing plugin. But I ran across a minor bug the other day.
I’m using a front-end system to post to the admin. I use a Custom Post Type and I’ve added some functions from Simple Fields. Everything works great except for checkboxes that has the option: Checked by default.
So, I post the posts with: wp_insert_post function.
As I said, I had the fields up and running for my CPT.
So far, so good. But on this particular site. You can update the contents in the post from the front end of things. Since the checkboxes is allready checked. They have the meta value of 1. Or they SHOULD have that. But they don’t. So I tought, perhaps if I add it manually like this after adding the post:
update_post_meta($post_id, ‘META_KEY’, $value);
add_post_meta($$post_id, ‘META_KEY’, $value, TRUE);
Delete the meta if it exist, then add.
I’ve tried so many things I’ve lost count. However, while doing one of theese options. I got it to work somewhat.
So. The method I use for unchecking the boxes is simply deleting the meta for the post: delete_post_meta($post_id, ‘META_KEY’);
It works but not in the admin! I can see the changes when I call on them from wordpress. And they work. But in the admin / on the post, the box is checked.
Unless! I enter the post before trying to update it from the front end. And just save it.
Now, I did compare my data in the database, compared to the one wordpress saves when I hit the update button. They are identical except for the meta_id (which I forgot the exact name of).
So, did I miss something or is it an actual bug? As I said. I got it to work if I: Add / Update right after wp_insert_post. But the admin bug still occurs (but it works).
Oh, and sorry for my wall of text!
- The topic ‘Checkboxes with Checked by default issue.’ is closed to new replies.