Need PHP function for Bulk Posting from External DB

This topic contains 7 replies, has 4 voices, and was last updated by  kenmoorhead 10 years, 1 month ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #16746

    kenmoorhead
    Free User
    Post count: 5

    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)

    #16757

    Guust
    Moderator
    Post count: 29970

    Have a look at
    http://docs.wpgeodirectory.com/core-general/#csv

    I 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.

    #16772

    kenmoorhead
    Free User
    Post count: 5

    That 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.

    #16846

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi 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

    #16999

    kenmoorhead
    Free User
    Post count: 5

    Thanks Stiofan. I’ll investigate this route a bit further.

    #17542

    kenmoorhead
    Free User
    Post count: 5

    I’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.

    #17548

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    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

    #17549

    kenmoorhead
    Free User
    Post count: 5

    Thank you. I thought I had posted it here in the jobs section to begin with.

Viewing 8 posts - 1 through 8 (of 8 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount