Why are the details of my todo not saving?

I created a todo plugin and when I add a new todo, the title of the todo saves, but the details I write in the wysiwyg do not save and neither does the due date.

Here is the code I believe is responsible for the expected behavior in my-todo-list-fields.php:

function mtl_todos_save($post_id){
$is_autosave = wp_is_post_autosave($post_id);
$is_revision = wp_is_post_revision($post_id);
$is_valid_nonce = (isset($_POST[‘wp_todos_nonce’]) && wp_verify_nonce($_POST[‘wp_todos_nonce’], basename(__FILE__))) ? ‘true’ : ‘false’;

if ($is_autosave || $is_revision || !$is_valid_nonce) {
return;
}

if (isset($_POST[‘priority’])) {
update_post_meta($post_id, ‘priority’, sanitize_text_field($_POST[‘priority’]));
}

if (isset($_POST[‘details’])) {
update_post_meta($post_id, ‘details’, sanitize_text_field($_POST[‘details’]));
}

if (isset($_POST[‘due_date’])) {
update_post_meta($post_id, ‘due_date’, sanitize_text_field($_POST[‘due_date’]));
}
}

add_action(‘save_posts’, ‘mtl_todos_save’);

I changed the $is_valid_nonce to !$is_valid_nonce, but that did not help.

Read more here:: Why are the details of my todo not saving?

Leave a Reply

Your email address will not be published. Required fields are marked *