How to sync roles across Multisite?

There’s an action hook in the set_role function. It’s a matter of detecting if this is happening in the main site, and, if it does, get all blogs of the user and change all roles. More details in code comments. add_action( ‘set_user_role’, ‘sync_user_roles_wpse_91745’, 10, 2 ); function sync_user_roles_wpse_91745( $user_id, $role ) { // is_multisite() used … Read more

wp_get_attachment_image_src returns incorrect URL on multisite

I found this stray code in the header.php $GLOBALS[blog_id] = get_option(‘woo_blog_id’); This wiped out the global variable that get_current_blog_id() relies on to get the site id in multisite. This is then used by wp_get_attachment_url() to build the appropriate URL. Because I was getting an incorrect site id, my attachment URLs were coming out wrong.

How do I show posts from another wordpress installation?

Non-Multisite setup: You need to create another instance of the WPDB Class. $newWPDB = new wpdb(‘Username’,’password’,’database’,’localhost’); $rows = $newWPDB->get_results(“you-query-here”); On WordPress Multisite: Does having WordPress MultiSite make things a lot easier or should we stick with single installations? There is the switch_to_blog() function available. You will need to restore_current_blog() after getting your results. Note that … Read more

get_last_updated() not working – multisite loop

You can try this instead of get_last_updated(): global $wpdb; $blogs = $wpdb->get_results(“SELECT blog_id, domain, path FROM {$wpdb->blogs} ORDER BY last_updated DESC” , ARRAY_A ); print_r($blogs); just to see if it changes anything to skip the public, archived, mature, spam , site_id and deleted filters.