Multisite – use one table?

This topic contains 16 replies, has 4 voices, and was last updated by  friendly fire 8 years, 9 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #21924

    Greg McEwan Marriott
    Buyer
    Post count: 36

    Hi… have plugin running with addons on a wp multisite installation. Wehave all our listings loading in the main blog , (which we use to allow members to comment, like share places as it is a buddypress social network).

    I was asked to install a subdomain blog called cities.mysite.com which would be geared to allow listing owners to manage their listings. Both sites need to “use” the same db table…

    I know that if i removed all references of $wpdb->prefix and replaced with $wpdb->base_prefix it would work… but is there maybe an easier function I could add to theme functions that would “globally” change it easier, rather than me having to edit the core plugin and add ons??

    Maybe a function using

    switch_to_blog( $site->blog_id );

    ??

    or

    
    
     global $wpdb;
          
          $base_prefix = $wpdb->get_blog_prefix(0);
          $base_prefix = str_replace( '1_', '' , $base_prefix );
    

    Best Regards

    #21925

    Greg McEwan Marriott
    Buyer
    Post count: 36
    #21928

    Greg McEwan Marriott
    Buyer
    Post count: 36

    If I am correct, only wp_posts and post meta would be not compat at moment? rest of tables are global

    
    
    add_filter('bp_core_get_table_prefix', 'sb_filter_bp_table_prefix', 2001);
    function sb_filter_bp_table_prefix($prefix ){
        global $wpdb;
        return $wpdb->prefix;
    }

    Here is an old function we used to allow us to insert a post into two blogs at the same time

    
    
    			// post to smeak.tv
    			
    			global $switched, $video_post_pe;
    			switch_to_blog(44);
    			$video_post_id = wp_insert_post($video_post);
    			update_post_meta($video_post_id, 'dp_video_url', $_POST['insert_video_link'], true);
    			$video_post_pe = get_permalink( $video_post_id );
    			restore_current_blog(); 
    #21932

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    HI Greg, i am not entirely sure what you are trying to do but the next release of all addons will make them fully multisite compatible which i don’t think is what you are after…

    Stiofan

    #21933

    Greg McEwan Marriott
    Buyer
    Post count: 36

    aah that is good news Stiofan… all i am really trying to achieve is to have the install on the 2nd blog use the same listings and locations on the main site…. i see all the geodir tables are global, except that the wp_posts and wp_postmeta tables are not “multiste” so on root blog it uses wp_posts and wp_postmeta and on say blog id 331 it uses wp_331_posts and wp_331_postmeta.

    So if u look in the sublog under Places you see no listings… this is because it is reading wp_331_posts and wp_331_postmeta and not wp_posts and wp_postmeta

    #21938

    Jeff
    Buyer
    Post count: 188

    Can I ask WHY you want users to login on this other site, rather than the main one? It seems like an over-complication for something that WordPress already handles.

    You’re going to run into permissions/security issues possibly and problems with other plugins outside of GeoTheme.

    #23478

    Greg McEwan Marriott
    Buyer
    Post count: 36

    users have one login across all sites in install … we have the listings site, and the 2nd is a buddypress social site that pulls in the listings as well in widgets allowing users to rate, and mark as favourites etc… places they have been to. The social site uses a completely different theme – which we have to retain, the listings in both the main blog and subsite have to be shared or the same on both.

    When you install the plugins at moment on the 2nd site – it does not totally share the posts across both blogs

    #23562

    friendly fire
    Buyer
    Post count: 37

    I’m actually very interested in solving this same issue.

    In my case, I want one DB of all the listings to share amongst all the subdomain sites.

    Ideally, they could still get access to the post types and add their own which would then feed into the core db tables and share amongst the rest of the site but i’d settle for the initial share for now.

    @greg, have you made any progress or have any leads as to the first place to start?

    #23576

    Greg McEwan Marriott
    Buyer
    Post count: 36

    @m33 – will keep you posted on this – I tried yesterday to replace all references to $wpdb->prefix with $wpdb->base_prefix which forces the plugin to use the “root” blog or site tables – that did not work as much as i wanted – i then tried replacing all db calls to $wpdb->posts. terms etc to wp_posts, wp_terms etc… that only got some parts working as in now at least i can see the locations taxonomy in the 2nd blog… also some listings show up now in 2nd blog, but not in admin….

    At the end of it this is not the way to go… what needs to be done is to have a network admin screen that asks if the plugin must be installed network wide or not.

    Before in another plugin we used the switch blog function to access any references to posts or terms and taxonomies… I will spend some time on this, for us a solution is not a “want” it is a MUST… without this we cannot use the system in our business model. Either way, any help or suggestions appreciated – Lets get this done !!!!

    Maybe a function using switch_to_blog( $site->blog_id );??

    or

    global $wpdb;

    $base_prefix = $wpdb->get_blog_prefix(0);
    $base_prefix = str_replace( ‘1_’, ” , $base_prefix );
    Best Regards

    #23606

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Greg, my honest advice would eb to abandon this idea, you will endup with a customised site which can never be updated to benifit from advances or updates.

    You can try adding a sugestions here and fully explaining your idea, if enough people are intrested then we would look into it but i can see us adding this feature otherwise.

    https://wpgeodirectory.com/requests/

    Stiofan

    #23621

    Greg McEwan Marriott
    Buyer
    Post count: 36

    tx – stiofan – i do not want to change the core plugin but abandon the idea i cannot – this is not a personal request from me – i have no choice as this is what i have to provide for the client – so trust me, i will do my best to share ALL i can and NOt try to change the core plugin – there are many multi site plugins, why is it so “impossible” to have a multisite wpgeodirectory plugin?

    I bought your old geodirectory/geotheme system many moons ago, and i did many changes to that and had that working fine on muktisite, i then also tried for over a year geomywp which IS multisite, i even integrated that into the DIRECTORY theme on themeforest… I decided to switch back to your system, as i felt you guys have done a great job so far and i would like to support you….

    as i said i don’t have the luxury of cannot… I MUST achieve this, i have no options, and i also know that NOTHING in programming is unachievable – to have a multisite version of your great system is NO train smash – it can be done

    #23627

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Yes but what you are after is not a multisite per-se.

    #23640

    friendly fire
    Buyer
    Post count: 37

    Greg, I just downloaded and installed the latest beta version (found in downloads if you’re an advanced member). I noticed that it does now support Multisite installations like Stiofan says. It seems to do this by adding the subsite’s prefix to the table geodir_post_locations and places. This is technically a true multisite supported plugin. However, our needs are a bit different as we want one shared set of locations and places amongst all subsites. In my case, I think the ability to allow people to update the master db from their install would be a nice bonus.

    Let me know if you come up with anything. I’ll keep digging as well in the interim. This may end up being a custom job that would deviate from the core.

    #23641

    friendly fire
    Buyer
    Post count: 37

    Also, was going to mention that the previous version I had installed did not recognize subsites so all locations and places did show up on subsites.

    It wasn’t intended to work with multsite before so maybe that it might be best to stick with that version as a starting point.

    #23645

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    If you can explain what each of you need/want in detail it will help me better understand because just now i am confused…

    Stiofan

Viewing 15 posts - 1 through 15 (of 17 total)

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

Open Support Ticket