CSV Importer
Setting serialized meta to not be reserialized on import (3 posts)

  1. n0ddles
    Posted 3 years ago #

    Hi guy's,

    I've noticed a problem where when I try to import a serialized feild into wordpress with csv importer.

    Say the field is :

    on import it reserializes the feild:


    Is there a way to code a feild header to bypass serialization?

    thank you for any help in advance!!!


  2. kjmagic13
    Posted 3 years ago #

    I had the same issue while trying to mass import products into eShop. Around line 539 of the csv_importer.php file I, using WordPress's is_serialized() function, edited the create_custom_fields() function to unserialize any values to be added to the post meta. In turn add_post_meta() re-serializes any arrays passed through the $meta_value (third) parameter.

    function create_custom_fields($post_id, $data) {
        foreach ($data as $k => $v) {
            // anything that doesn't start with csv_ is a custom field
            if (!preg_match('/^csv_/', $k) && $v != '') {
                // if value is serialized unserialize it
                if( is_serialized($v) ) {
                    $v = unserialize($v);
                    // the unserialized array will be re-serialized with add_post_meta()
                add_post_meta($post_id, $k, $v);

    You could also set it to perform a certain task depending on a specific key.

    if( $k == '_eshop_product' ) {
        $v = unserialize($v);
        // etc., etc.

    Hope this helps.

  3. bheadrick
    Posted 3 years ago #

    Added this to my forked version

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • CSV Importer
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic