WP_User_Query::get_cache_last_changed()wp-includes/class-wp-user-query.php | Retrieves the last changed cache timestamp for users and optionally posts.
|
user_can_for_site()wp-includes/capabilities.php | Returns whether a particular user has the specified capability for a given site.
|
current_user_can_for_site()wp-includes/capabilities.php | Returns whether the current user has the specified capability for a given site.
|
wp_initialize_site()wp-includes/ms-site.php | Runs the initialization routine for a given site.
|
wp_uninitialize_site()wp-includes/ms-site.php | Runs the uninitialization routine for a given site.
|
wp_is_site_initialized()wp-includes/ms-site.php | Checks whether a site is initialized.
|
get_oembed_response_data_for_url()wp-includes/embed.php | Retrieves the oEmbed response data for a given URL.
|
WP_Site::get_details()wp-includes/class-wp-site.php | Retrieves the details for this site.
|
has_custom_logo()wp-includes/general-template.php | Determines whether the site has a custom logo.
|
get_custom_logo()wp-includes/general-template.php | Returns a custom logo, linked to home unless the theme supports removing the link on the home page.
|
wp_get_users_with_no_role()wp-includes/user.php | Gets the user IDs of all users with no role on this site.
|
get_site_icon_url()wp-includes/general-template.php | Returns the Site Icon URL.
|
WP_MS_Sites_List_Table::column_blogname()wp-admin/includes/class-wp-ms-sites-list-table.php | Handles the site name column output.
|
confirm_another_blog_signup()wp-signup.php | Shows a message confirming that the new site has been created.
|
wpmu_delete_user()wp-admin/includes/ms.php | Deletes a user and all of their posts from the network.
|
upload_space_setting()wp-admin/includes/ms.php | Displays the site upload space quota setting form on the Edit Site Settings screen.
|
wpmu_delete_blog()wp-admin/includes/ms.php | Deletes a site.
|
WP_Users_List_Table::get_views()wp-admin/includes/class-wp-users-list-table.php | Returns an associative array listing all the views that can be used with this table.
|
WP_Importer::set_blog()wp-admin/includes/class-wp-importer.php | |
WP_User::get_role_caps()wp-includes/class-wp-user.php | Retrieves all of the capabilities of the user’s roles, and merges them with individual user capabilities.
|
WP_Theme::get_allowed_on_site()wp-includes/class-wp-theme.php | Returns array of stylesheet names of themes allowed on the site.
|
get_home_url()wp-includes/link-template.php | Retrieves the URL for a given site where the front end is accessible.
|
get_site_url()wp-includes/link-template.php | Retrieves the URL for a given site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.
|
wp_admin_bar_my_sites_menu()wp-includes/admin-bar.php | Adds the “My Sites/[Site Name]” menu and all submenus.
|
count_users()wp-includes/user.php | Counts number of users who have each of the user roles.
|
newblog_notify_siteadmin()wp-includes/ms-functions.php | Notifies the network admin that a new site has been activated.
|
create_empty_blog()wp-includes/ms-deprecated.php | Create an empty blog.
|
get_blog_post()wp-includes/ms-functions.php | Gets a blog post from any site on the network.
|
add_user_to_blog()wp-includes/ms-functions.php | Adds a user to a blog, along with specifying the user’s role.
|
remove_user_from_blog()wp-includes/ms-functions.php | Removes a user from a blog.
|
get_blog_permalink()wp-includes/ms-functions.php | Gets the permalink for a post on another blog.
|
get_blog_option()wp-includes/ms-blogs.php | Retrieves option value for a given blog id based on name of option.
|
add_blog_option()wp-includes/ms-blogs.php | Adds a new option for a given blog ID.
|
delete_blog_option()wp-includes/ms-blogs.php | Removes an option by name for a given blog ID. Prevents removal of protected WordPress options.
|
update_blog_option()wp-includes/ms-blogs.php | Updates an option for a particular blog.
|
get_blog_details()wp-includes/ms-blogs.php | Retrieves the details for a blog from the blogs table and blog options.
|
wp_xmlrpc_server::wp_getUsersBlogs()wp-includes/class-wp-xmlrpc-server.php | Retrieves the blogs of the user.
|
Multiple switches
If you do not call restore_current_blog() after every switch_to_blog() , WordPress can get into a state that can potentially build the wrong urls for the site. See restore_current_blog() vs switch_to_blog() .
I was a little confused with the
switch_to_blog()functionality when I first started using it. This function only affects the database which is being accessed on the network. I cannot access blocks of code, classes, functions, or variables that exist within a specific blog on the network. By extension, this also means that I cannot access themes or plugins that only exist on one site on the network. I was hoping for a little more power with this function before I realized that this was limited to site data being stored in the database.The following example does not work:
Site 1 --> Site1_only_plugin --> Site1_only_plugin_function()That is, Site 1 has a unique plugin that has a bit of functionality that I want to access on Site 2 (or anywhere else on the network) without loading the full plugin to Site 2. I might be tempted to do something like this from Site 2:
This does not work. I can only use the
switch_to_blog()functionality to access database values from other sites on the network. Here’s an example that does work:Site 1 --> Site1_only_plugin --> Site1_only_plugin_function()--> add_option( 'Site1_only_plugin_option', $var )The plugin on Site 1 has first set a value in the Site 1 database. I can then access that value in the options table from anywhere on the network as follows:
One switch
Description
Restores previous blog after a switch_to_blog call.
Contrary to the function’s name, this does NOT restore the original blog but the previous blog. Calling `switch_to_blog() ` twice in a row and then calling this function will result in being on the blog set by the first `switch_to_blog() ` call.
When using
switch_to_blog()outside of WordPress, you need to have the global$switcheddefined. The variable for defining which blog ID to target, may also not be$blog_id, because it is used by WP Core.The below example will not create a post within the correct blog_id, unless
$switchedis defined.It’s important to note that
switch_to_blog()does not check whether a blog actually exists for the supplied ID. You could potentially switch to a non-existant blog and run queries against non-existant tables.