Need PHP function for Bulk Posting from External DB
This topic contains 7 replies, has 4 voices, and was last updated by kenmoorhead 11 years ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
September 28, 2014 at 1:16 am #16746
I’m looking for a function I can use in the process of bulk posting business data I have in another MySQL table in my WP database.
Config: I have the WPGD plugin as well as the MultiLocation addon.
I have a MySQL table (call it “schools”) that contains listings for many Brazilian Jiu Jitsu academies. This table gets updated with new academies daily. I’ve hit a snag in the process between taking the data from this schools table and getting it processed correctly by the GD plugins.
What I would like is a php function that accepts an associative array of location data and publishes new Places posts using it. I’ve become overwhelmed with the number of functions in the GD code and am not sure what all needs to be called, and with what data, in order to publish a post.
My schools table has the following information to provide as GD posts:
1) business ID (with a corresponding custom field on GD posts)
2) Name
3) Phone
4) Street Address
5) City
6) State / Region
7) Zip
8) Country (as 2-character ISO code, not proper country name)
9) Latitude (only populated for some entries)
10) Longitude (only populated for some entries)September 28, 2014 at 7:33 am #16757Have a look at
http://docs.wpgeodirectory.com/core-general/#csvI think you’ll find is that you just have to create the CTP, the categories and then prepare your CSV file to upload to GD > General > CSV.
Let me know if I misunderstood.
September 28, 2014 at 2:58 pm #16772That would work, for a one-off upload. My source table is going to be continually updated with new locations and I really want something that can be used as part of scheduled tasks on my server. I’m needing help with one (final) step of an automation process I’ve built most of… To give context, here’s the process.
1) Query data provider API using zip codes (Done)
2) Retrieve schools near zip code and insert location data into MySQL table (Done)
3) Query MySQL schools table for schools that are not in WPGD directory (Done)
4) Retrieve school data from MySQL table and create WPGD Places Posts with it (Partially done. I’ve started constructing the loop that would insert data for each school, but don’t have a WPGD function to submit to)If there’s a wrapper for the CSV upload I can use, or another existing function, I’d be very happy to go that route. As it stands, I’ve not found that in the documentation or something clear in the code for the plugin of a function(s) I could use to get there.
September 29, 2014 at 8:18 am #16846Hi Ken,
We just hook into the save_post hook with the function “geodir_post_information_save” you should have a look there which leads onto the function “geodir_save_listing”
Thanks,
Stiofan
September 30, 2014 at 4:34 pm #16999Thanks Stiofan. I’ll investigate this route a bit further.
October 5, 2014 at 5:35 pm #17542I’ve been able to find the WPGD function I need, but I’m just being dragged down a rabbit hole of additional WP functions needed to support it. My PHP skills just aren’t that good and I need someone more familiar with writing for WordPress to assist.
Can anyone help with this? It’s simply beyond the scope of my abilities for the time I have right now.
October 5, 2014 at 6:48 pm #17548Hi,
unfortunately it goes also beyond the scope of this support forum.
I’ve moved this topic in the Jobs section to see if any developer would be able to take on this challenge for you.
Thanks
October 5, 2014 at 6:51 pm #17549Thank you. I thought I had posted it here in the jobs section to begin with.
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket