• Resolved phrk

    (@phrk)


    Hello, am I missing something obvious? When importing meta key with integer value, it is imported as a string, e. g. 1234 as [“1234″] or ‘a:1:{i:0;s:4:”5919”;}’ (as shown in phpmyadmin). Is there any easy way to import integer numbers as numbers? Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Javier Carazo

    (@carazo)

    @phrk,

    This is always managed as a string because in CSV we read strings.

    Anyway, update_user_meta, for example, does not manage the data as integer, so where have you seen some WP managing some meta data as integer?

    Thread Starter phrk

    (@phrk)

    Sorry, I wrote a nonsense 🙂
    Value “1234” from the CSV is imported as an array – [“1234″] in the meta field or ‘a:1:{i:0;s:4:”1234”;} in the database. The target fields are of type “text”. Fields of type “boolean” are correctly imported (value “1” as true).

    Plugin Author Javier Carazo

    (@carazo)

    Could you show me how are you importing this value in your CSV?

    Thread Starter phrk

    (@phrk)

    Sure! I tried this:
    “ID”
    1234

    and

    “ID”
    “1234”

    with the same result – meta text field “ID” in user profile containing [“1234”].

    Thanks!

    Plugin Author Javier Carazo

    (@carazo)

    Yes, sure, but this is how WordPress save the data into meta.

    Meta can be array or object, so it always save it in this way.

    Which is the problem :s?

    Thread Starter phrk

    (@phrk)

    So – if I understand it correct – there is no straightforward way how to save the number as a pure string to the meta field using your plugin. I will solve it other way. Thank you for great support, marking as solved.

    Plugin Author Javier Carazo

    (@carazo)

    @phrk,

    No this is not a problem of this plugin, this is a problem of how WordPress works: https://developer.ww.wp.xz.cn/reference/functions/update_user_meta/ check this function.

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Import integer as integer’ is closed to new replies.