0

( sorry for the title, but i dont know how to explain this as a title ^^ ).

I'm using really simple csv importer to bulk import data in my site, using Advanced custom fields.

So i need to import some data as serialized data. So i used the hook "really_simple_csv_importer_save_meta_filter" as show in docs.

But i have an issue, the hook just explain how to filter serialized data, but not how to keep normal data. So it works well with my 2 serialized columns, and delete all the other columns.

how can i custom my hooks to keep other columns active ?

my columns :

post_type post_title contact_city seo_h1 marche_tel rank_math_title marche_periode marche_h_debut marche_h_fin marche_www marche_latitude marche_longitude marche_maps marche_dpt type_un type_deux type_trois jour_un jour_deux jour_trois jour_quatre jour_cinq jour_six jour_sept

my hook :

function really_simple_csv_importer_save_meta_filter( $meta, $post, $is_update ) {
    $meta_array = array();

    $metas = [
        'marche_jours' => ['jour_un', 'jour_deux', 'jour_trois', 'jour_quatre', 'jour_cinq', 'jour_six', 'jour_sept'],
        'marche_type' => ['type_un', 'type_deux', 'type_trois'],
    ];

    foreach ($metas as $metaKey => $metaFields) {
        foreach ($metaFields as $field) {
            if (isset($meta[$field])) {
                $meta_array[$metaKey][] = $meta[$field];
            }
        }
    }

    return $meta_array;
}
add_filter( 'really_simple_csv_importer_save_meta', 'really_simple_csv_importer_save_meta_filter', 10, 3 );
0

Answear is available here with explaination (french). https://www.wpnuls.fr/import-csv-de-champs-acf-avec-really-simple-csv-importer-740.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.