Solved

Importing data into serialized array in Wordpress

Posted on 2014-10-20
4
463 Views
Last Modified: 2014-12-18
I have creating website for a basketball league. I used Formidable Pros for the front end registration and payments. I am now using sportpress pro to set up players, teams, schedules,etc. I created  a csv file that I was going to import in sportpresspro database but found out they are not using tables but postmeta data instead of tables. Is there a way to import my data into this array. Thanks
0
Comment
Question by:Hidesign
  • 2
  • 2
4 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40392690
Almost all plugins that store data will store it as key-value pairs in some meta table.  Formidable does this, Gravity does this, etc.

What you think of when you want to import is a single CSV into a vanilla row/column format table and obviously that won't quite work if the plugin has no import routine.  What you need to do instead is figure out the structure of the meta tables in play and run a series of imports via MySQL to fully upload your data.

For example, assuming the plugin creates a custom post type then you need to figure out what gets posted in the wp-posts table (probably the team).  From there do a simple insert query to add all teams to wp-posts and then extract the ID numbers.  From there you can build queries that create new rows in whatever tables are needed, making sure to include the post ID number when necessary.
0
 

Author Comment

by:Hidesign
ID: 40392789
Thanks - the plugin does come with an import feature but it only imports 7 set fields. I wanted other fields in addition so I don't have to retype them. I want to import the players with height, weight, grade and contact info. One of the preset fields is postion and I was thinking about putting the grade in that field if I can figure out how to change the text in the backend to say grade instead of position.

I was looking through the wp_postmeta table to see how it laid out. There is so much data that is not related to the players so I'm sure how to update.
0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 total points
ID: 40392952
It's not the easiest thing in the world to see unless you are very familiar with WordPress and, furthermore, wp_postmeta is not the only thing in play here.  I'll try to explain:

wp_postmeta has four columns:

meta_id = autoincrementing primary key
post_id = the ID of the post this meta relates to
meta_key = the name of the meta item
meta_value = the value of the meta item

This construction means you can have a one-to-many relationship between a post item (which are a custom post type) and postmeta.  Postmeta is primarily used for custom fields...so anything in this system that appears in postmeta can be replicated/updated by query.  To determine what is in postmeta, go to the All [Whatever] screen and hover over any edit link.  In the URL will be an ID number for that team.  That's the post_id.  Search for that in postmeta:

SELECT * FROM wp_postmeta WHERE post_id = X

Open in new window


and you will see how the custom fields for teams are constructed and you should be able to figure out how to manipulate from there. You just search on post_id and/or meta_key to narrow it down.

But, in all likelihood, the data you really want is stored elsewhere.

I want to import the players with height, weight, grade and contact info.

Because this is a paid plugin, I can't really see what is going on with it so I'm making some guesses here.

If players are users then that data will be in usermeta.  Same basic rules as postmeta, just different tables.  The plugin probably adds some user custom fields but you can do the same thing with some extra code in functions.php:

http://wpengineer.com/2173/custom-fields-wordpress-user-profile/

or via one of several plugins. The problem with this is that the  SportsPress plugin will not be aware of these other fields so you may end up having to hack it to get them in there properly.  I would suggest checking with their support line to find out the best way to do this.
0
 

Author Comment

by:Hidesign
ID: 40406665
Hi - thanks for the info - I'm going through it and the code to see if I can get this working. I'm hoping I can get this data imported. Will take too long to key it all in
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now