How to set Active plugins as the default screen?

There are two options, modify the menu link href attribute or redirect the main screen. Modify menu Alter the global variable $submenu. This method works for Single and Multisite. Problem: the submenu item Installed Plugins doesn’t show in bold. add_action( ‘admin_head’, ‘b5f_plugins_redirect_to_active’ ); function b5f_plugins_redirect_to_active() { global $submenu; $submenu[‘plugins.php’][5][2] .= “?plugin_status=active”; return; } Redirect page … Read more

Default content for a new site in multi site

You could use a run-once plugin. The following is just some made-up code, not even tested. See it as a guide, not as a solution. 🙂 <?php /* Plugin Name: T5 Default Site Settings */ /* * Don’t start on every page, the plugin page is enough. */ if ( ! empty ( $GLOBALS[‘pagenow’] ) … Read more

Limit multisite/network site names to a property of the user

Looking at the source of wp-signup.php, it looks like your best bet might be to filter signup_blog_init (line 303 in v. 3.5.1): /* add_filter( ‘signup_blog_init’, ‘wpse103022_blog_name’ ); function wpse103022_blog_name( $blog_details ) { // Set $username to the user’s username $blog_details[‘blogname’] = $username; return $blog_details; } */ // see code below for replacement I’m not 100% … Read more

How to use both British and American English?

You can filter mu_dropdown_languages and re-add American English here. Sample code, not tested: add_filter( ‘mu_dropdown_languages’, function( $output, $lang_files, $current ) { array_unshift( $output, ‘<option value=””‘ . selected( $current, ‘en_US’, false ) . ‘>’ . __( ‘American English’ ) . “</option>” ); return $output; }, 10, 3 ); Filter sanitize_option_WPLANG or pre_update_option_WPLANG to jump into the … Read more

WP_INSERT_POST issue on WordPress Multisite

The hook declaration takes 6 parameters, yet none is in your function’s definition. Also, before calling the hook wpmu_new_blog, WP does a restore_current_blog(), so it’s safe to assume that we have to switch to the destination blog before inserting content. add_action( ‘wpmu_new_blog’, ‘new_blog_wpse_115724’, 10, 6 ); function new_blog_wpse_115724( $blog_id, $user_id, $domain, $path, $site_id, $meta ) … Read more

Display site admin profile fields in header.php

Ok I figured a way to do it. If anyone else is interested, here’s the code. It first gets the user id of the admin of the blog, and then it uses the id to pull the meta from the profile fields. For one field — <?php $thisblog = $current_blog->blog_id; $user_id_from_email = get_user_id_from_string( get_blog_option($thisblog, ‘admin_email’)); … Read more

Installing multisite network admin on sub-domain

Yes. Here are the instructions: Install and configure WP for www.example.com Configure multisite – can use either sub-domain or sub-directory Install WP Domain Mapping plugin – http://wordpress.org/plugins/wordpress-mu-domain-mapping/ Create new site, e.g. site1 Using Domain Mapping plugin, map site (site1.www.example.com or www.example.com/site1) to preferred sitename (site1.example.com) I actually have two separate WP sites setup as above, … Read more

WordPress Multisite: Have the same header and footer of main-blog on all sub-blogs

You could use the switch_to_blog() function Switches the active blog until the user calls the restore_current_blog() function. This function is useful if you need to pull posts, or other information, from other blogs, you can then switch back after using restore_current_blog(). Using this function will not load plugins that only run on the blog you … Read more

Using $wpdb Class to Pull Recent Comments Across a Network

Why not use get_comments(), instead of trying to roll your own with $wpdb? function display_sitewide_comments() { $sites = wp_get_sites(); $network_comments = array(); $max = 20; foreach( $sites as $site ) { switch_to_blog( $site->blog_id ); $args = array( ‘number’ => $max, ‘status’ => ‘approved’, ); $network_comments[$site->blog_id] = get_comments( $args ); restore_current_blog(); } // inspect the comments … Read more