Thanks to ‘dvkob’ for the great CSVImporter plugin, which I simplified for this specific use. I also include and use the File_CSV_Datasource class by Kazuyoshi Tlacaelel exactly as it was found in the CSV Importer plugin. All their GNU/MIT copyrights are passed through.
Team rosters can be loaded from files in CSV format. This allows admins to load their team roster(s) from an Excel spreadsheet, which is often used to create printed rosters. With the release of version 4.0, the CSV export/import process also translates v 3.1.2 data structures to the much richer version 4.0 structures. So the CSV Import Rosters admin screen (shown below) can be used to bulk import rosters created in Excel for printed rosters, and it can be used to move sites within or across WordPress installations. Sample CSV files may be downloaded from the CSV Sample Files man page. If you are importing bulk rosters that you created, I recommend you first successfully import the samples provided, then modify them for your own needs. The remainder of this page explains the controls on the CSV Roster Import admin screen. For details on the CSV file formats, see the CSV File Formats man page.
Teams CSV File. Select a Teams CSV file from local storage.
Import Teams. Press to import the teams in the selected CSV file. NOTE: teams that already exist in the DB will be ignored.
Select Team to Import. Use this control to select an existing team in the Teams DB. This control should be used if the CSV file does not contain a
player_teams column; for example, when the players on one team are being bulk imported from a CSV file. When a CSV file is created by the MSTW CSV Exporter plugin, the
player_teams column will contain entries, so any team selected in this control will be ignored. See Notes & Discussion below for more info.
Move Player Photos. If this checkbox is checked, the plugin will attempt to copy the player photo files specified in the
player_photo column from their existing location to the sites media gallery. So this checkbox should be UNCHECKED for a simple site update where the existing player photos do not need to be moved, and CHECKED when a site is being moved to a different WordPress site.
Players CSV File. Select the Players CSV file from local storage.
Import Players. Press to import the players in the selected CSV file. Note: unlike teams, duplicate players WILL be imported.
NOTES & DISCUSSION
- New Fields. In version 4.6 two new fields – long position (
player-position-long) and long year (or class) (
player-year-long) – that were added in version 4.4 were added to the CSV inport and tested with the single player file (TR-Players-import-One-player.csv).
- Load Times. When you press an Import button, the plugin goes about its work silently. Maybe someday I’ll get to a progress bar or spinner of some sort, but until then, BE PATIENT. If you are importing a large set of players, the import may timeout. This is not a problem with the plugin. More likely, this is your shared server preventing your processes from hogging server resources. The fix is simple enough; just break your CSV file up into smaller files. Remember to include the header row in each file.
- Player Title. If a player (row) does not have an entry in the
player_title(column), the import function will attempt to create one from the
player_last_namecolumn entries. Otherwise, the player (custom post) title defaults to “No first or last name.”
- Player Slug. If a player (row) does not have an entry in the
player_slug(column), one will be created from the player title (created as described above).
- Player Teams. If a team or teams is/are specified in the
player_teamscolumn, it/they will be used. If no team is specified in the
player_teamscolumn, the team selected in the
Select Team to Importcontrol will be used. Otherwise the player will be imported, but will not be on a team. The player will not appear on the front end until he/she is assigned to a team.
- Multiple Teams. You can now import multiple teams in one file by using the
player_teamscolumn to specify the different teams, or you can import one team without a
player_teamscolumn by specifying the team for all the players in the
Select Team to Importcontrol. You can even specify teams in the
player_teamscolumn AND specify a team in the
Select Team to Importcontrol. In this case the team specified in the
Select Team to Importcontrol becomes the ‘default’ team if the
player_teamscolumn contains no entry for a player.
- Player Photos. You are only going to use the
player_photocolumn if the file is created by MSTW CSV Exporter. It will contain the URLs of any existing player photo files. If you are simply updating Team Rosters on an existing site, there is no need to copy the player photo files, just leave them where they are at (the site’s Media Library) by leaving the
Move Player Photoscheckbox UNCHECKED. If you are moving your Team Rosters data from one site to another, then CHECK the checkbox. The plugin will then attempt to copy the old site’s photo files to the new site’s Media Library.
- Player Bio. The
player_biocolumn entry will be stored in the player post’s content field.
- Missing Columns/Entries. Unless discussed above, missing fields are ignored.