Ocean Conservancy uses two third-party plugins to facilitate and manage cleanup locations from within the WordPress CMS. The first is a form generation plugin called Gravity Forms and the second is an import tool called “WP All Import”.
This form generation plugin was selected for it’s seamless ability to save single location data as a new post as well as the way it’s code is generated – which provided us the freedom to style the forms consistent with the approved design comps. When a person completes the single submission form on the live site, (Found here: https://oceanconservancy.org/trash-free-seas/international-coastal-cleanup/add-cleanup-location/), that submission is saved as a new post in the “Map Locations” post type as a draft. Changing the publishing status from “Draft” to “Published” instantly makes that location visible on the map. (More information on map data posts…)
While we also use the Gravity Forms plugin to accept multiple-location / CSV submissions, these must be saved as entries inside of Gravity Forms’ entry database. This is because there is not currently a method for parsing each row of a CSV on the fly and saving each to a new post. Instead, one must navigate to the submitted and saved entry, download the CSV, and import it using “WP All Import”.
Each time a form is successfully submitted, an email is automatically sent to email@example.com notifying the recipient that a new entry now exists in the database. Entries can be found by navigating to Forms > Entries in the WordPress CMS left-hand sidebar menu.
On this page, you will find a table containing the successful multi-submissions. (Note: There is a bug that prevents us from removing the disclaimer column from this table. It’s a required field, so there’s no real reason for it to display here. A fix is underway).
Click directly on the small file icon in the “Your CSV File” column and it your browser will prompt you, or automatically download the submitted CSV file (depending on your local settings).
While the submission form will validate the user’s selected CSV file by ensuring that the file is indeed a CSV and that the headers match our sample file, it’s recommended that the CSV file is reviewed before preparing to import it’s entries in to the “Map Locations” post type.
Importing Locations from CSV File
Navigate to All Import > New Import the WordPress CMS left-hand sidebar menu.
Select “Upload a file”
By default, “import data from this file into…” will direct you to import as “New Items”. Next, be sure to select “Map Locations” as the custom post type selection. Then click, “Continue to Step 2”.
No actions are needed for Step 2, so click “Continue to Step 3”.
On Step 3, scroll all the way to the bottom until you see this section:
Click on the select menu and choose “TFS Locations Map”
Once selected, the page will reload with all of the necessary settings for importing the location in data into the correct fields. IMPORTANT: These settings presume that you have reviewed the CSV data and are comfortable with these map locations going live once the import is complete. If you would prefer that these locations remain drafts and not be live once the import is complete, click on “Other Map Location Options” and change the “Post Status” to “Draft”.
No action is necessary for Step 4, simply scroll down and click “Continue”.
Finally, begin the import.
Deleting an Import
If after you have completing an import, you realize that the import contained bad data, or if someone were to request that their locations be removed, the entire import can be deleted. First, navigate to the Manage Imports page.
On this page, you will find a list of all the imported CSVs. Find the import in question, and click the delete link. On the next page select the “Delete posts created by file.csv” checkbox. If the CSV contained images, you will also want to check “Delete associated images from media gallery.”
Important: this will delete all posts generated from the import. If you only need to fix a single location it would be easier to edit that location manually.