How can I get multisite primary blog (url or path) for current user?

Indeed, get_active_blog_for_user should work. $blog = get_active_blog_for_user( get_current_user_id() ); $blog_url = $blog->domain… /* or $blog->path, together with $blog->siteurl */ Alternatively: $blog_id = get_active_blog_for_user( get_current_user_id() )->blog_id; // note: changed “->userblog_id” to “->blog_id” in row above to make it work. switch_to_blog( $blog_id ); /* switch context */ $home_url = home_url(); restore_current_blog(); /* back */

Exclude main blog from get_blogs_of_user

If you drop this line in your code, you will see all the properties of $user_blogs. echo ‘<pre>’.print_r($user_blogs,true).'</pre>’; One of them is userblog_id, so you just have to check against it before echoing the blogname. <?php $user_blogs = get_blogs_of_user( $user_id ); if (!$user_blogs) { echo ‘no blogs’; } else { echo ‘<div><ul>’; foreach ( $user_blogs … Read more

How to get the site administrator/s by blog id

In shortcode form: /** * Shortcode for listing all admin users of a Multisite site * * Usage: [siteadmins blog=”1″] */ add_shortcode(‘siteadmins’, ‘wpse_55991_site_admins’); function wpse_55991_site_admins($atts, $content = null) { $site_admins=””; switch_to_blog( $atts[‘blog’] ); $users_query = new WP_User_Query( array( ‘role’ => ‘administrator’, ‘orderby’ => ‘display_name’ ) ); $results = $users_query->get_results(); foreach($results as $user) { $site_admins .= … Read more

Recover from failed multisite conversion

If you still have access to your wife’s blog, I would recommend: Running a regular WordPress export of the content Downloading the entire /wp-content directory over FTP These are the two most important parts of the site – the content and the uploads. From this, you should be able to recreate the site on a … Read more

Logout issue with new Domain on WP Multisite

I asked on the WordPress MU Domain Mapping plugin support page and it turns out it was a setting in the plugin that needed to be turned off. I turned off Redirect administration pages to site’s original domain and it’s working now. Thanks for your ideas and help!

Deleting a user in multisite

I ended up figuring this out a while ago… completely forgot to post it here. Once I added the include properly it worked: require_once(‘./wp-admin/includes/ms.php’); if ( $user ) { wpmu_delete_user( $user->ID ); } For the sake of future readers here was the final code: function handle_gateway_return() { $GWPass = get_option( $this->gateway . “_gateway_gwpass” ); if … Read more

Multisite WordPress nginx uploaded files throw 404

I solved the problem by upgrading the way files are uploaded and displayed to the new WordPress 3.5 method. A more detailed tutorial can be found at http://halfelf.org/2012/dumping-ms-files/ but the basic steps are as follows: Move images from blogs.dir/#/files/ to /uploads/sites/#/ Change WordPress settings so it doesn’t look in /files/ but in /uploads/sites/#/ In .htaccess … Read more