Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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.


share|improve this question
2  
Research here in WordPress Development, I think you'll find bits and pieces to build a stronger Question. Check the faq and the How to Ask page: useful resources to learn the specifics of the Q&A Stack style ;) –  brasofilo Feb 16 '13 at 22:03
1  
@brasofilo - I've made changes to my question and added in sources that had items that were close to what I was looking for, but not close enough to actually provide a legitimate answer. –  Chris LaFay Feb 17 '13 at 1:25
    
I upvoted the Q for the good description and research, but I'm not sure there is a "correct Answer" for this. Too many complex topics: 1) Custom content on site creation, answer here. 2) User registering and management/permissions. 3) Shared content. And here, points 1 and 2 play a role. Maybe, maybe, and that's just my opinion, you should focus the Q on point 3. I imagine a hidden custom field in each page that links to the main site and the template pulls the global information without the user being able to modify this (CF or template). –  brasofilo Feb 17 '13 at 2:16

1 Answer 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.

share|improve this answer
    
DOING_AUTOSAVE and wp_is_post_revision($post_id) should be accounted for inside save_post callback. ::: How to get all blogs IDs - in $blogs=. –  brasofilo Feb 17 '13 at 5:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.