WordPress.org

Ready to get started?Download WordPress

Forums

Store Locator Plus
Mashup after polling user meta in Multisite Network (5 posts)

  1. kirkward
    Member
    Posted 1 year ago #

    I have a mutlisite network. Admin profiles contain user meta with city names, street addresses, and post codes. I can retrieve the location information on each individual site by using the following code:

    <?php
    $user_id_from_email = get_user_id_from_string( get_blog_option($thisblog, 'admin_email'));
    $current_site_admin = get_userdata($user_id_from_email);
    ?>
    
    <div style="font-weight: bold; font-size: 18px; line-height: 125%;">
    <font color="blue"><?php echo (get_user_meta($current_site_admin, 'practicename', true)); ?></font><br />
    <?php echo (get_user_meta($current_site_admin, 'officestreet', true)); ?><br />
    <?php echo (get_user_meta($current_site_admin, 'officecity', true));?>, <?php echo (get_user_meta($current_site_admin, 'officestateprovince', true)); ?> <?php echo (get_user_meta($current_site_admin, 'officepostcode', true)); ?><br />
    <?php echo (get_user_meta($current_site_admin, 'officephone', true)); ?><br /><br />
    </div>

    How can I retrieve that data from each site in the network of blogs and save it so SLP can show all locations on the main site?

    http://wordpress.org/extend/plugins/store-locator-le/

  2. Charleston Software Associates
    Member
    Plugin Author

    Posted 1 year ago #

    You will need to write a multi-site processing loop then store the data into the SLP table. There is a lot of documentation on the http://www.charlestonsw.com site about extending data, the hooks and filters, and plenty of code in the add-on packs that manipulate the data store.
    http://www.charlestonsw.com/support/documentation/technical-documentation/

    You'll need to write your own code to hook into the save locations process, but other than that it is a fairly simple "flat" data table format.

  3. kirkward
    Member
    Posted 1 year ago #

    Well piddle.

    That's going to be over my head.

  4. kirkward
    Member
    Posted 1 year ago #

    Then again, maybe not. I think I've made progress.

    Does it mess with anything else if I merely insert/create a new row in the wp_store_locator table and update the following fields ?

    Fields to update:
    sl_id
    sl_store
    sl_address
    sl_city
    sl_state
    sl_zip
    sl_country
    sl_url
    sl_image
    sl_private - Null
    sl_neat_title - Null
    sl_pages_url - Null
    sl_pages_on - Null
    sl_lastupdated - Time
    sl_option_value - Null

    Then, geocode from the dashboard?

  5. kirkward
    Member
    Posted 1 year ago #

    I was able to cobble this together from searches done on the web. I confirmed that I was retrieving the correct data by using a php echo statement to list the data on the page before attempting the section that inserts it into the table. I added the table stuff, but the data is not being entered into the table.

    What do I need to change in order to get it to save the map info?

    Thanks

    <?php
    $bcount = get_blog_count();
    
    global $wpdb;
    $blogs = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE spam = '0' AND deleted = '0' and archived = '0' and public='1'"));
    if(!empty($blogs)){
        ?><ul class="menu"><?php
        foreach($blogs as $blog){
            $details = get_blog_details($blog->blog_id);
            if($details != false){
                $addr = $details->siteurl;
                $name = $details->blogname;
                $blognum = $details->blog_id;
                if(!(($blog->blog_id == 1)&&($show_main != 1))){
                    ?>
    
                    <li class="menu-item<?php if($counter == get_current_blog_id()){ echo ' current-menu-item';}?>">
                        Blog ID = <?php echo $blognum; ?><br />
                        Blog URL = <?php echo $addr; ?><br />
                        Blog Name = <?php echo $name;?><br />
    <?php
    $user_id_from_email = get_user_id_from_string( get_blog_option($blognum, 'admin_email'));
    $current_site_admin = get_userdata($user_id_from_email);
    
    $kw_fname = (get_user_meta($current_site_admin, 'first_name', true));
    $kw_lname = (get_user_meta($current_site_admin, 'last_name', true));
    $kw_admin_email = get_bloginfo ( 'admin_email' );
    $kw_practice_name = (get_user_meta($current_site_admin, 'practicename', true));
    $kw_office_phone = (get_user_meta($current_site_admin, 'officephone', true));
    $kw_office_city = (get_user_meta($current_site_admin, 'officecity', true));
    $kw_office_street = (get_user_meta($current_site_admin, 'officestreet', true));
    $kw_office_state = (get_user_meta($current_site_admin, 'officestateprovince', true));
    $kw_office_zip = (get_user_meta($current_site_admin, 'officepostcode', true));
    ?>
                    </li>
    
                    <?php
                }
            }
        }
        ?></ul><?php
    }
    
    $data = array(
        'sl_id' => $blognum,
        'sl_store' => $kw_practice_name,
        'sl_address' => $kw_office_street,
        'sl_city' => $kw_office_city,
        'sl_state' => $kw_office_state,
        'sl_zip' => $kw_office_zip,
        'sl_country' => ,
        'sl_url' => $addr,
        'sl_image' => ,
        'sl_private' => NULL,
        'sl_neat_title' => NULL,
        'sl_pages_url' => NULL,
        'sl_pages_on' => NULL,
        'sl_lastupdated' => current_time('mysql', 1),
        'sl_option_value => NULL
    );
    
    $wpdb->insert(wp_store_locator, $data);
    
    ?>
    
    <h1>Done!</h1>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.