You could simply use the get_blogs_of_user()
function:
echo count( get_blogs_of_user( $user_ID ) );
instead of your custom SQL query.
Related Posts:
- get_user_meta() to Return User Meta Only for Current Blog in Multi Site
- Is there a wordpress function to cleanly delete an entry in the signups table?
- Exclude main blog from get_blogs_of_user
- Get users primary blog URL in MultiSite
- How to Move Local Singlesite Database to Remote Multsite Database?
- How to store custom user data on the database?
- Query users by capability – uninstall/deactivate callback
- WPML tables not deleted when removing multisite subsite, need help clearing up my sql-file! [closed]
- How is a user’s primary blog determined?
- Database Tables Lost Indexes? How to Recover?
- List recent 25 blogs across the network
- 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’
- WP MultiSite: Can’t select database error after changing to new domain
- Minimize Performance Issues of MultiSite Large Number of Tables Created
- WPMU add custom colum
- Can I replace the “Upgrade Network” with SQL query?
- Get users from all/specific blog by user_role and current_user role
- How does adding custom meta to signup form work?
- Why are my roles not visible in a Multi-site/Network?
- How to use same email for multiple users
- How will self-hosted WordPress work with Google Page Speed Service?
- What is the best way to load the WP environment in a subdomain of my multisite WordPress install?
- Mega WordPress Applications WPMU or otherwise
- Does the WordPress API work with multisite?
- wp_get_attachment_image_src multisite issue
- Transfer Subdomain site to Multisite setup
- WP REST API – Multisite – get posts from all sites
- How to Login Once to an Entire WP Multisite Network
- How properly delete only one site (blog) from the Network in WordPress Multisite (WPMU)
- What is the best way to setup wordpress development environment for freelancers with version control?
- Multisite sub-site dashboard redirects to /wp-admin/
- Trying to access second site dashboard on a multisite configuration proceeds to an error
- Get source from the_post_thumbnail
- Favicon plugin for WordPress running in network mode (multisite)? [closed]
- WordPress Multisite with VVV
- How do I park secure.primary.com on top of the multisite ID:1 domain: www.primary.com (primary multisite domain)
- WordPress multisite,one theme,and different languages?
- Removing /blog/ from multisites cause infinite redirection
- Has anyone seen a ‘visual anatomy’ type graphic of the Buddypress plugin?
- Alias domain to Multi-site installation in Apache
- Custom rewrite rule sends 404 header on multisite
- WordPress multisite subdirectory on nginx behind reverse proxy
- Multiple WordPress Blogs on one host, using 1 WordPress installation, using multiple templates
- How to use the “domain_exists()” function
- Woocommerce Multisite Get Orders from Another Site
- Subdomains With WordPress
- Assign role to user on first login, if they are first (after admin)
- Avoid having infinite loops
- Pretty Link Lite Plugin on WP Multisite
- WPMU Development Environment
- turn single domain off
- WordPress Multilingual Theme using Multisite
- use get_sites subsite_id with get_bloginfo”() and/or get_custom_logo
- How can I update dev links for a live site?
- Multisite – One user allowed access to all sites?
- How to recover deleted site in WordPress Multisite?
- Entry page for a wordpress multisite
- WordPress Multisite dashboards redirect to homepage
- WordPress with Tor Onion Service (dual .com & .onion domains for same website)
- Use external database with local multisite
- URL redirect/rewrite rule wordpress multisite
- Issue with wp_get_attachment_url() function for multisite
- Networksite/multisite is disabled ?, Why?
- My subdomain on WordPress Multisite has gone
- How to have yearly versions of same site with different content (like yearly conferences)?
- Network Admin URL is shown to anyone before accessing a blog
- Canonical Resource URLs Across a Multisite Network 2012?
- how to migrate wpmu from one host to the other?
- Multisite WPLANG won’t save
- Child Theme Based on Toolbox Not Found
- Limit blogs creation
- How To Disable Add new users On Subsites In Multisite?
- MultiSite: new Sites not showing up
- Create a CSS file in plugin folder when theme is activated
- What is the best method of installing WP on multiple add-on domains?
- switch_to_blog() not functioning while querying post_types, Why?
- Different site different div content – Multisite
- Installing wordpress on a subfolder of adsense approved domain
- can’t create user without email for an author after converting single site to multisite
- Launch Media Library for specific MU site
- Redirect Function Prevents Images from Showing in Front-end Media Uploader
- multiple domains point to same site on WP-MU
- How to convert multisite subdomain from http to https
- One membership area for two websites
- Define a new sub-folder naming – Multisite
- Multisite install in a subfolder won’t work with www
- Domain mapping breaks some plugin scripts and css
- How to force WP to create a users table in multisite configuration?
- Creating a stand-alone site from a WordPress sub site
- Whats a good strategy for localising WordPress post and page content?
- Updating themes customized by users
- WordPress and multisites, the rigth choice?
- Multisite pagination with get_posts
- Best Way to Setup a Network of WP Sites?
- 404 error in dashboard of subdomain of multisite
- WordPress Multisites
- The wpmu_blogs_columns filter is not working