pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.06k stars 265 forks source link

Empty values for Input Number field in User meta don't get default values #7222

Open LC43 opened 7 months ago

LC43 commented 7 months ago

Description

When using a Plain Number field in user meta, in a group, the default values aren't saved when saving the profile. when the process goes go this:

if ( null === $value || ( '' === $value && 'boolean' === $type ) || ( ! empty( $pod ) && empty( $id ) ) ) {
    $value = self::default_value( $value, $type, $name, $options, $pod, $id );
}       

the $value is an empty array: array(0), so it doesn't enter this condition.

i added

if ( empty( $value ) ) {
    $value = self::default_value( $value, $type, $name, $options, $pod, $id );
}

Version

3.0.8

Testing Instructions

  1. Create a group in user meta
  2. Create a Plain number with a default value, Enable HTML5 Input Field, and set placeholder
  3. create a new user
  4. check that the default value isn't saved

Screenshots / Screencast

No response

Possible Workaround

if ( empty( $value ) ) {
    $value = self::default_value( $value, $type, $name, $options, $pod, $id );
}

Site Health Information

`
### wp-core ###

version: 6.4.1
site_language: pt_PT
user_language: pt_PT
timezone: +00:00
permalink: /%postname%/
https_status: true
multisite: false
user_registration: 0
blog_public: 1
default_comment_status: undefined
environment_type: production
user_count: 3
dotorg_communication: true

### wp-paths-sizes ###
[...]

### wp-active-theme ###
[...]

### wp-themes-inactive (0) ###

### wp-plugins-active (9) ###
[...]
Pods - Custom Content Types and Fields: version: 3.0.8, author: Pods Framework Team, Actualizações automáticas desactivadas

### wp-plugins-inactive (0) ###

### wp-media ###

image_editor: WP_Image_Editor_Imagick
imagick_module_version: 1690
imagemagick_version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
imagick_version: 3.7.0
file_uploads: 1
post_max_size: 64M
upload_max_filesize: 64M
max_effective_size: 64 MB
max_file_uploads: 20
imagick_limits: 
    imagick::RESOURCETYPE_AREA: 122 MB
    imagick::RESOURCETYPE_DISK: 1073741824
    imagick::RESOURCETYPE_FILE: 768
    imagick::RESOURCETYPE_MAP: 512 MB
    imagick::RESOURCETYPE_MEMORY: 256 MB
    imagick::RESOURCETYPE_THREAD: 1
    imagick::RESOURCETYPE_TIME: 1.844674407371E+19
imagemagick_file_formats: 3FR, 3G2, 3GP, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DJVU, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, H, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, JBG, JBIG, JNG, JNX, JPE, JPEG, JPG, JPS, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV
gd_version: 2.3.3
gd_formats: GIF, JPEG, PNG, WebP, BMP, XPM
ghostscript_version: 9.50

### wp-server ###

server_architecture: Linux 5.15.0-86-generic x86_64
httpd_software: nginx/1.18.0
php_version: 8.0.30 64bit
php_sapi: fpm-fcgi
max_input_variables: 10000
time_limit: 30
memory_limit: 512M
max_input_time: 60
upload_max_filesize: 64M
php_post_max_size: 64M
curl_version: 7.68.0 OpenSSL/1.1.1f
suhosin: false
imagick_availability: true
pretty_permalinks: true
current: 2023-12-03T13:19:43+00:00
utc-time: Sunday, 03-Dec-23 13:19:43 UTC
server-time: 2023-12-03T13:19:42+00:00

### wp-database ###

extension: mysqli
server_version: 10.3.38-MariaDB-0ubuntu0.20.04.1
client_version: mysqlnd 8.0.30
max_allowed_packet: 16777216
max_connections: 151

### wp-constants ###

WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: [...]
WP_PLUGIN_DIR: [...]
WP_MEMORY_LIMIT: 512M
WP_MAX_MEMORY_LIMIT: 256M
WP_DEBUG: true
WP_DEBUG_DISPLAY: true
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: false
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_ENVIRONMENT_TYPE: Indefinido
WP_DEVELOPMENT_MODE: undefined
DB_CHARSET: utf8
DB_COLLATE: undefined

### wp-filesystem ###

wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable

### pods ###

pods-server-software: nginx/1.18.0
pods-user-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0
pods-session-save-path: /var/lib/php/sessions
pods-session-save-path-exists: Sim
pods-session-save-path-writable: Sim
pods-session-max-lifetime: 1440
pods-opcode-cache-apc: Não
pods-opcode-cache-memcached: Não
pods-opcode-cache-opcache: Sim
pods-opcode-cache-redis: Não
pods-object-cache-apc: Não
pods-object-cache-apcu: Não
pods-object-cache-memcache: Não
pods-object-cache-memcached: Não
pods-object-cache-redis: Não
pods-memory-current-usage: 16,942M / 512M
pods-memory-current-usage-real: 18,000M
pods-network-wide: Não
pods-install-location: /assets/plugins/pods/
pods-developer: Não
pods-tableless-mode: Não
pods-relationship-table-enabled: Sim
pods-relationship-table-status: 0
pods-light-mode: Não
pods-strict: Não
pods-allow-deprecated: Sim
pods-api-cache: Sim
pods-shortcode-allow-evaluate-tags: Não
pods-sessions: Disable sessions
pods-can-use-sessions: Sim
pods-settings-types_only: Não
pods-settings-watch_changed_fields: Não
pods-settings-metadata_integration: Sim
pods-settings-metadata_override_get: Não

`

Pods Package

{
                            "name": "a_type1",
                            "id": 2981,
                            "label": "a",
                            "description": "Discount for Type 1 ( Auto parts )",
                            "weight": 0,
                            "type": "number",
                            "sister_id": "-- Select One --",
                            "required": "0",
                            "number_format_type": "number",
                            "number_format": "i18n",
                            "number_decimals": "0",
                            "number_format_soft": "0",
                            "number_step": "1",
                            "number_max_length": "3",
                            "number_html5": "1",
                            "repeatable": "0",
                            "repeatable_format": "default",
                            "roles_allowed": "administrator",
                            "enable_conditional_logic": "1",
                            "rest_pick_response": "array",
                            "rest_pick_depth": "1",
                            "conditional_logic": {
                                "action": "show",
                                "logic": "any",
                                "rules": [
                                    {
                                        "field": "client_type",
                                        "compare": "=",
                                        "value": "type1"
                                    }
                                ]
                            },
                            "default_value": "60",
                            "number_placeholder": "60",
                            "number_min": "0",
                            "number_max": "100"
                        },