• Jenny

    (@enigma666666)


    Great plugin, thank you!
    I was wondering if there is possibly some php code that I can add, to enable all existing data to automatically be deleted upon uploading a new CSV file? In other words, instead of overwriting existing data, I need for all existing data to be deleted when I upload a new CSV file. I will need to do this daily.

    If this is not possible at all, can you perhaps tell me which php code in the plugin to edit, so that on the participants list page in admin, all records will be shown, without pagination, to enable bulk deletion, without scrolling through many pages of entries? I can’t seem to set the limit of items displayed to more than 900. I have close to 10 000 records in the list and need to be able to select all records with 1 click, to bulk delete, if I can’t find code to enable auto bulk delete upon new CSV import.

    I have looked at bulk delete plugins, but participants database does not appear in the lists of custom post types inside any of those plugins, so I cannot uses a bulk delete plugins.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Jenny

    (@enigma666666)

    I should mention that once the website is live, then the website editor will be uploading the new CSV files daily and also do the bulk deleting of participants list entries. I therefore need a solution that does not involve manually truncating the data records in PhpMyAdmin.

    Plugin Author xnau webdesign

    (@xnau)

    Probably the best way to do this is to create custom code that truncates the table.

    You could set this up on a filter (pdb-before_csv_store_record) that is used when a CSV is uploaded, but that means the table would be truncated every time a CSV is uploaded, you may not want that. You’d also need to set up your filter so that it only truncates the table before the first record is uploaded, since that filter is called on every record in the upload.

    Another approach would be a custom plugin that your editor would use to truncate the table before performing the upload. You’d need to set up that plugin to provide a button or something that the editor would click to do the truncation.

    There isn’t anything built into Participants Database that would do this, you’d need to create your own code to make this happen.

    Thread Starter Jenny

    (@enigma666666)

    Thank you, I would prefer going with pdb-before_csv_store_record, as particapant details will be different in each csv file upload.

    I have added the following code, but it is not working, so my code is obviously incorrect. If you could perhaps point to me where I am making a mistake in the code, it will be greatly appreciated.

    add_filter(‘pdb-before_csv_store_record’, ‘wp_participants_database_truncate’);
    function wp_participants_database_truncate($post) {
    global $wpdb;
    $delete = $wpdb->query(“TRUNCATE TABLE ‘wp_participants_database'”);
    }

    Also, once I get the above code working, I would like to remove the preferences displayed on the xnau_CSV_Import.php page in wordpress admin, as it will not be needed. If I edit xnau_CSV_Import.php, will that suffice or must I remove hooks first via functions?

    Plugin Author xnau webdesign

    (@xnau)

    To hide those options, a better approach is to use custom CSS to hide them. The plugin has a setting for custom CSS in the admin side. Don’t modify the plugin directly, you will have to restore those modifications every time the plugin is updated.

    Your filter fallback needs to pass the $post array through, otherwise the record won’t be written because it won’t get the data.

    Also, you can’t have it truncate the table on every record, you need to set up your code so that it will only truncate before the first record is saved.

    Thread Starter Jenny

    (@enigma666666)

    Great, thank you very much for pointing me in the right direction, much appreciated. Will do as you suggested.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Bulk Auto-Delete Records upon new CSV upload’ is closed to new replies.