• Resolved C. Spencer Beggs

    (@spencerbeggs)


    Hi, scribu,

    I ran across another zero-as-a-value related bug. When I input a value of zero for a custom post meta field, the plugin was deleting the old value because the string ‘0’ is treated as empty in PHP, though one would want to retain the ability to have the meta value be deleted if it is truly empty. I hacked the save function in my post.php file like so to get round this:

    if ($new_value === '0')
    			update_post_meta( $post_id, $key, $new_value, $old_value );
    		else if (!$new_value)
    			delete_post_meta( $post_id, $key, $old_value );
    		else
    			update_post_meta( $post_id, $key, $new_value, $old_value );

    Thanks again for this wonderful plugin.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Suggestion: Test for 0 on Meta Value Save’ is closed to new replies.