Get users primary blog URL in MultiSite

I’m trying to get the primary blog URL of a user. What I have works to grab the details, but if there is more than one blog it just returns them all 🙁

$user_id = get_current_user_id();
$user_blogs = get_blogs_of_user( $user_id );
foreach ($user_blogs AS $user_blog) {
echo $user_blog->siteurl;
}

How can I modify this to output the primary blog URL of the current user?

I’m not sure how to pull it from wp_usermeta primary_blog table, but that may do the trick.

What I would like is the URL from the user primary blog so when they login from the network main site and visit the account area, it shows links to various areas without directing them to the you attempted to access message first…

Read more here:: Get users primary blog URL in MultiSite

Leave a Reply

Your email address will not be published. Required fields are marked *