Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Takuro Hishikawa

    (@hissy)

    I tested with similar data below, but any post meta values were not deleted.

    “post_type”,”post_id”,”list-state”
    “post”,72,”Radovljica”
    “post”,73,”Tolmin”
    “post”,74,”Mozirje”

    Could you send me or upload your actual csv file?

    Thread Starter nicole2292

    (@nicole2292)

    Certainly I can send the whole file, however that is all the content within the actual CSV file. A CSV with exactly that content and nothing else is deleting all meta data for those posts. There were more lines in my csv but I removed them as I was inadvertently deleting a lot of metadata and I have to restore my database after every test. Luckily I have a backup.

    How can I send the file to you? I cannot see a way to attach a file on here or to message you privately?

    Can I email you?

    Thanks,
    Nicole

    Plugin Author Takuro Hishikawa

    (@hissy)

    Plugin Author Takuro Hishikawa

    (@hissy)

    I’ve tested with the data which you send me, but post meta data were not deleted. I’m sorry, but I can’t reproduce the error.

    Thread Starter nicole2292

    (@nicole2292)

    Thank you very much for that.

    There must be a clash with another plugin or something. I will do some further testing and post my findings here.

    Nicole

    Thread Starter nicole2292

    (@nicole2292)

    Ok after a thorough investigation I have tracked this issue down to a clash with another plugin. The one which is responsible for the custom post type “hut”. I cannot simply disable this plugin to import my csv as then the custom post type “hut” does not exist.

    We have a function which resembles this:

    add_action("wp_insert_post", array(&$this, "wp_insert_post"), 10, 2);
    
    function wp_insert_post($post_id, $post = null) {
    
        if ($post->post_type == "hut") {
    
          foreach ($this->meta_fields as $key) {
    
            $value = @$_POST[$key];
    
            if (empty($value)) {
    
             //Below is the troublesome line which deletes all post meta.
             delete_post_meta($post_id, $key);
    
              continue;
    
            }
    
            //More code here that is not relevant.
         }
    }

    This function is clearly being executed when the CSV import is being performed and consequently it is deleting all the post meta.

    I don’t want to edit your plugin code so do you have any ideas how I could change the above code so that it is not activated when your csv plugin runs?

    Thank you very much,
    Nicole

    Plugin Author Takuro Hishikawa

    (@hissy)

    I can’t understand why that plugin deletes all post meta data. Weird.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Deleting all post meta on import’ is closed to new replies.