We had a question come up at WP Wed regarding getting the root site ID in Multisite.
I had been using a magic number*:
switch_to_blog( 1 ); // 1 is a magic number
Then I switched to using the semi-obtuse constant in wp-config.php as that seems safer (in the rare case that would change):
switch_to_blog( SITE_ID_CURRENT_SITE ); // current root site, not current site user is browsing
Then Justin Foell ran across some code using a function I'd never seen before:
get_dashboard_blog(); // Huh?
Which returns the blog details for a blog that may or may not be the current site, and apparently may or may not be the root site either. It checks an option called dashboard_blog, but there doesn’t seem to be anywhere that can be modified (it appears nowhere else in the core code from what I can tell).
It gets a mention in the help tab but has no field on the Network Settings page:
Dashboard Site is an option to give a site to users who do not have a site on the system. Their default role is Subscriber, but that default can be changed.
Seems like the constant is the right way to go, and the dashboard_blog is a 3+ year old vestige of WPMU that may has not been fully removed or deprecated.
This Trac ticket backs this conclusion up:
That was a fun spelunking adventure into core!
And I just opened my first Trac ticket as a result:
_________________________
Nick Ciske
@nciske