Shared Content but “Updatable” Through the Main Site

I have been doing quite a lot of research the past week, and have not been able to find a solid answer that fixes my problem. So, I decided to come here to ask to see if anyone knows of how to help with my problem.

I’m going to working on a project using WordPress Multisite that will allow users to register for a site and be able to re-brand the content that we will be giving them as their own (ie: the company I will be working with has a slew of realtor information that they want to give away – for a fee – to other realtors and allow them to brand it with their logo and contact info).

Read More

So, it would be easy to create a template site with all the content already pre-loaded. When MS creates a new site, it grabs the template and creates the new site using the template.

However, I need to be able to modify this content across all sites. We will have approximately 50 pages that need to be “shared” throughout all these sites, and if I need to make a change, I need to change across the board. I have tried using this

<?php switch_to_blog(1); ?>
Some code that displays the menu of the Main Blog
<?php restore_current_blog(); ?>

But that will link everything to the main site (which defeats the purpose of paying to have the content branded as your own). I have found plugins that allow you to broadcast posts to all your sites, but this is content that will be preloaded.

With all of that said, I am hoping someone around here has done this before and is willing to share some expertise on the matter. Thanks for taking a look at this!


EDIT #1

I’ve done my research through the WordPress support forums as well as here at StackExchange.

Is there a way to share content amongst wordpress sites :: This option doesn’t really work for me – I have to be able to charge for users to set up their new sites as well as give them the option to add their domain name to their site, which is why Multisite is the way I believe I need to go.

Re-Blogging – WP MS Support Forum :: This is what I have found the most of – ways to re-blog content across all platforms. If I needed to shoot out posts to everyone, that would be great. However, this is not what I would like to accomplish.

Exactly what I am looking for :: But sadly there isn’t an answer.

I did a search through WordPress Answers of variations of “multisite content share” and found nothing (other than #3) that pertained to my topic (or what I am looking for in general)


EDIT #2

So, after doing some more research yesterday, I found ThreeWP Broadcast. It happens to do quite a lot of what is actually needed, but hid itself during my first few days of research. It allows you to broadcast pages throughout all subsites as well as send out updates to those pages as well. Awesome! So, a new question arises. My client doesn’t want the end users editing their content (copyright and legal reasons). So, I wrote some code that automatically appends some JS to the top of the Edit Page in the backend:

function hidePublishingNow() {
global $blog_id, $wpdb;
$prefix = "ssr_";


if(is_super_admin()) {}
else {



    $page = $_GET['post'];
    $pageFound = false;


    if($page > 0 && isset($blog_id)) {
        $sql = "SELECT * FROM ssr__3wp_broadcast_broadcastdata WHERE blog_id = $blog_id";
        $results = $wpdb->get_results($sql, "ARRAY_A");

        foreach($results as $r) {
            if($r['post_id'] == $page) { $pageFound = true; }
            else {}
        }

        if($pageFound == true) {
            wp_enqueue_script(
                'hide-publishing',
                get_template_directory_uri() . '/js/removePublishing.js',
                array('jquery')
            );
        }
    } else {}
}

} add_action(‘admin_head’, ‘hidePublishingNow’);

Basically, when the post.php is loaded within the admin panel, it checks to see if the current page being edited is a page that has been connected via Broadcasting. If it has been connected, the JS is loaded and removes all elements to that page and replaces it with a warning. The end user will never see the content in the editor or be able to Update the page.

That is working well. If this is what I have to go off of, that’s great – it’s the best solution I have found yet. What I would love to do would be to take control of the main wp-admin/edit.php?post_type=page page (this is where the admin panel lists out all the pages available for editing). It would be great to intercept a WP action when it is making that list and strip out specific pages while it is creating that list. Still doing research on it to see if that is even possible. I just wanted to update my progress on here in case anyone has a word of advice, or down the road if someone else is running into this same issue.


Related posts

Leave a Reply

1 comment

  1. You can update the sub sites when the main site is updated. Assuming your post IDs for the duplicated content remain the same as the same post in the main site you can write a plugin which runs only on the main site and with every save updates the sub sites

    add_action('save_post','wase87206_broadcast');
    
    function wase87206_broadcast($post_id) {
      $mainurl = get_option('siteurl');
      $post = get_post($ost_id);
      $blogs = get ids of all valid sub sites
      foreach ($blogs as $blogid) {
        switch_to_blog($blogid);
        $siteurl = get_option('siteurl');
        $post->post_content = str_replace($mainurl,$siteurl,$post->post_content); // fix links
        wp_update_post($post);
      }
      switch_to_blog(1); // set context back to main site
    }
    

    NOTE: this is only a skeleton for the code, as was commented below you might not want to duplicate revisions, auto saves or some specific content that should be displayed only on the main site. Another thing omitted here is handling of post deletion.

    You will need the same type of code to sync categories and tags and meta data. to keep images synced the easiest way is to have a symbolic link from the upload directory of the sub sites to the upload directory of the main site.

    You need to look into the performance of this type of code so it will not run into the php time limit, into memory limits, or just annoying wait until the save is completed, so you might need to recode it to use scheduled events which update only some of the blogs in one go and fire another event to continue updating the others.