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.

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.

How many databases do I need?

Multiple installs can share a single database, as long as each install has a unique table prefix defined in wp-config.php before going through the install process: /** * WordPress Database Table prefix. * * You can have multiple installations in one database if you give each a unique * prefix. Only numbers, letters, and underscores … Read more

Generate HTTPS Urls in multisite

Instead of get_option, use home_url which will determine … the appropriate protocol, “https” if is_ssl() and “http” otherwise. If the $scheme argument is “http” or “https” the is_ssl() check is overridden. In fact, network_home_url would be more appropriate since you are talking about Multisite. Those should return the same value that you are trying the … Read more

MultiSite: new Sites not showing up

It appears your sites are not under the same network, and you have network 1 and network 3. Normally this would never happen on an average multisite unless plugins are installed that can change this. Yes 1 WordPress multisite instance can run multiple networks of blogs, you have accidentally stumbled onto this feature, wordpress.com being … Read more

How to Deny Access to No Referrer Requests on Multiste with Mapped domains

You could hook intop pre_comment_on_post: add_action( ‘pre_comment_on_post’, function(){ if ( empty ( $_SERVER[‘HTTP_REFERER’] ) ) exit; }); But … be aware, not all requests without an referer are actually spam posts. Some firewalls and proxies strip this field. And most automated spam comes with a Referer field filled with the name of the spammed domain. … Read more

How To Disable Add new users On Subsites In Multisite?

To remove the Add Users capability from Administrators (but leave it intact for Super Administrators), you can do this: <?php $role = get_role( ‘administrator’ ); if ( $role->capabilities[‘add_user’] == 1 && ! is_main_site( get_current_blog_id() ) ) { // Because this is saved to the database, we check first // to see if it’s already been … Read more

Limit blogs creation

The signup page has validation hooks. How about something like this? add_filter(‘wpmu_validate_blog_signup’,’set_blog_creation_limit’); function set_blog_creation_limit($result) { $blogs = get_blogs_of_user($result[‘user’]->ID); if (count($blogs) > 2 ) $result[‘errors’]->add(‘blogname’, __(‘You have already registered the maximum amount of blogs!’)); return $result; }