I need to add custom item to WooCommerce My Account navigation. I can add the item with no problem. Since it is a link to user's profile I use the following code:

  global $switched;
<a href=”<?php echo bp_loggedin_user_domain(); ?>”>Profile</a>
<?php restore_current_blog(); //switched back to main site ?>

First I switch to BuddyPress which handles users (multisite newtork). Then I use bp_loggedin_user_domain to get user profile url.

But the actual output of the link is incorrect, I get: www.domain.com/my-account/"www.subdomain.domain.com/members/profile/"

I know that My Account page treats all links as child pages with WooCommerce endpoints, but is there a way to get the external url there? Without WooCommerce's default domain.com/my-account/ prefix

2 Answers 2


Making a small assumption here. It's more likely that the actual output looks something like this:

<a href="www.subdomain.domin.com/members/profile">

rather than:

<a href="www.domain.com/my-account/www.subdomain.domain.com/members/profile/">

And your browser is actually filling in for the missing scheme and path. Browsers will assume an href is relative if you don't use an absolute URI (go figure!) so if you're using external links you need to be sure there's a // at the start(or an https://, or http:// etc.). Else the browser will insert the appropriate relative path for you, in the case of a missing / it will insert the current full path for the link, effectively providing:

<a href="http://www.domain.com/my-account/www.domain.com/members/profile/">

Use view-source, not dev tools, in your browser to see the raw output, rather than the interpreted & formatted output to be sure though.

  • Thanks for the help. Unfortunately, My Account page keeps adding it's own prefix url and not even switch_to_blog bypasses this. It will always give current newtork site url / network site / profile as soon asa you add somting to a tag.Although I did manage to bypass this by using: <?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?> Commented Jun 12, 2017 at 13:48

This is how I solved my problem:

I have a multisite network on domain.com, there is also BuddyPress which handles user profiles on buddypress.domain.com. When user registers it often happens on domain.com because we have a webshop there. So I wanted to add BuddyPress profile link to WooCommerce My Account navigation.

When I added it with:

<a href=”<?php echo bp_loggedin_user_domain(); ?>”>Profile</a>

I would get the following link in frontned www.domain.com/"buddypress.domain.com/members/user" instead of buddypress.domain.com/members/user

I think this is because of the way WooCommerce handles My Account page. Basically it treats each link on that page as an endpoint and inserts the domain.com part. It treats every link on it as a child page.

Since I'm on a tight schedule with the project I used this instead:

<?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?>

which showed Username and profile link correctly. Since this is a multisite I used it with switch_to_blog();

So If anyone needs to play with WooCommerce and BuddyPress on multisite network, I hope this will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.