There’s actually a function for that: get_active_blog_for_user()
https://developer.wordpress.org/reference/functions/get_active_blog_for_user/
$user_id = get_current_user_id();
$user_blog = get_active_blog_for_user( $user_id );
echo $user_blog->siteurl;
Related Posts:
- get_user_meta() to Return User Meta Only for Current Blog in Multi Site
- SQL to check how many sites a user is a member of
- Exclude main blog from get_blogs_of_user
- How to store custom user data on the database?
- Query users by capability – uninstall/deactivate callback
- How is a user’s primary blog determined?
- User Role is Not Specifying in WordPress Multisite?
- Solving a get_user_meta() problem in Multisite
- get_user_meta() in multiste with respect to subdomain
- Delete all user’s meta without knowing all the ‘key’
- WPMU add custom colum
- Get users from all/specific blog by user_role and current_user role
- How does adding custom meta to signup form work?
- Site admin in a network install can’t edit users?
- Querying posts from multiple sites in a network?
- is_front_page() malfunction?
- How can I diagnose a slow WordPress admin?
- How to enable a site administrator to edit users in a WordPress network/ multisite setup?
- BLOG_ID_CURRENT_SITE vs. SITE_ID_CURRENT_SITE in WordPress Multisite?
- Shared table across network
- Opinions whether to go multisite VS 3 separate WP installation [closed]
- Multisite: differences between subdomain and subdirectory mode? Can it be switch after installation?
- Ban SiteNames Multisite
- WP MultiSite API – Create new sites
- Multisite – sub-subfolders for certain blogs
- Multisite behind Varnish
- How do I know if a user has a blog in WordPress Multisite?
- Multisite – how to remove the root ‘/’ site?
- Configure WordPress to read from database only, never write
- WordPress multisite with domain mapping and virtual host on local with fake domain
- Don’t allow access to wp-admin but allow admin-ajax requests to be fulfilled on frontend?
- Timeout While Upgrading Network in Multi-site
- Full Domain Mapping with WP3 in Multiuser Mode
- How to migrate WordPress Blogs into Multisite without using the GUI-Import/Export Feature
- WordPress network (multisite) /wp-admin/ redirect loop (ERR_TOO_MANY_REDIRECTS)
- Suppress subdirectory from WordPress Multisite primary URL
- Has anyone experience w/ WordPress (MultiSite) hidden users (possibly hacked)?
- Why wordpress multisite redirect to wp-signup if site exists?
- How to combine multiple sites to WordPress MU
- Installing multisite network admin on sub-domain
- Is it possible to import a wordpress backup from a single site in to a multi-site configuration?
- Multiple domains with different child themes on one installation?
- Global searchin multisite but only with one subsite
- Subdirectory multisite installation with several domain names?
- create_users capabilities on a role on multisite
- Hosting a seperate wordpress project on localhost
- Removing a wordpress multisite installation and preserving the database before migrate to nginx
- How to change user starting role in WordPress MultiSite?
- Add additional non-rewrite .htaccess directives on multisites via mod_rewrite_rules filter
- get_post_type_object() does not work with switch_to_blog()
- How to change the parent Domain Name in Multisites Project?
- Multi-Site Subdomain: Show master site under subdomain if no sub site exists
- Register existing user on another site in a multisite network?
- WordPress MultiSite Theme
- Can i import a site (plugins, database, images) etc. Into an existing wordpress multisite?
- Create Custom Multisite User Role to Reduce Capabilities
- Importing XML didn’t finish, site is now inaccessible
- WordPress multisite – Bitnami
- One blog inside another
- Change Default WordPress MU Blog
- wordpress multisite permalink structure: mostly subdomains but not all
- how to create wordpress network with multiple wordpress installations
- How to get blog_id of an MU site when running a custom function on the parent site
- Multiple sites with independent users
- Programmatically creating site in a network
- What happens when someone goes to the root URL in WordPress Multisite?
- Migrate single site to Multisites with plugins, cPanel and already working subdomains
- Multisite WP-API json v2 : can i fetch all comments on all sites with a single query?
- how to install wordpress HyperDB
- Using Same User Database on Subdomain
- Change language for each website using multisite
- Automatic creation of mutisite blog outside of the admin
- Trying to Decide Between Reverse-proxy and Multisite
- Automatically add a registered user on the wordpress multisite network even to just one other site
- Redirecting specific sites to HTTP in WordPress Multisite
- wp-cli core install –skip-email and –skip-config flags not working on MAMP unknown parameter
- WordPress Multisite VMware copy for dev use not allowing loggin
- Multisite network subdomains doesn’t work
- MULTISITE: Password issue and Error Cant access site
- trying to install a wordpress multisite in a subfolder and have custom subsite urls
- Accessing WP multisite via IP instead of domain
- Running hosted multisite version of wordpress
- Multisite,half the way
- Create new multisite from existing and keep domain?
- Admin Ajax returns “0 200 OK server error..” in Multi-site sub-site
- WordPress Multisite: an official and definitive way to enable https ? (http to https)
- How to implement this subdirectory mapping in multisite?
- WordPress MU with subdomain
- How do i get custom metabox data from each multisite blog?
- Multisite login and redirect to users main blog,
- What dictates whether a plugin will be available to a site in a multisite install?
- How do I setup WordPress Multisite in it’s own directory?
- Parse shortcodes from another site in WP Multisite
- Custom pages on all multisite network, to NOT show in wp-admin at all
- Install WordPress MU outside htdocs
- How do I remove ‘www.’ from all internal links in self-hosted multisite?
- WordPress Multisite platform for different city for single db
- Not being allowed to use some terms in Add New Site in WordPress
- How to redirect root blog to a specific one in multilang WP?
- WordPress multisite with subdirectories always redirects to mainsite