Skip Navigation

[Resolved] A default value of zero in numerical custom fields is not an integer

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 0 replies, has 1 voice.

Last updated by Gavin 1 month ago.

Author
Posts
#2817446
The Custom Fields in the back-end.png
Example Custom Field.png
php error log.png

Hi Team

I wonder if you could test this out as it seems to be a consistent bug I am encountering.

I have a post type with custom numerical custom fields that are set to ZERO - 0 - as their default (see custom field image).

The custom post type is being created in PHP. I do not set the custom fields to zero because they are already set to zero as their 'default'.

When I run PHP code using the custom fields I am getting a PHP error because it thinks the numerical value is a string and not an integer (see PHP error image).

However. if I 'update' the post in the admin panel, then the numerical custom fields now indeed contain an integer with a value of zero and the PHP code works.

Thanks.

#2817459

Okay - so default values are only present when the post is 'SAVED' and not when the post is 'CREATED'.