I am using the Multisite feature enabled. I have a main site and a community site. On the main site the 'Edit My Profile' links is pointing to this link:


But when I am visiting my community site the 'Edit my Profile' link points to this link:


I want the link on the main site to show the exact link as my Community site is showing which is an extended BuddyPress profile. So, I went ahead and added this filter to my main site's functions.php:

add_filter( 'edit_profile_url', 'my_modified_profile_url', 10, 3 );

function my_modified_profile_url( $url, $user_id, $scheme )
    $current_user = wp_get_current_user();
    $url = site_url( '/community/members/' . $current_user->user_login . '/profile/edit/' );
    return $url;

This returns the exact URL that I want and it includes the username in the URL which is perfect. Is this the proper way of doing it?

I used $user_id in this line:

$url = site_url( '/community/members/' . $user_id . '/profile/edit/' );

But that returned the user ID number and the link was broken.

  • I used the same filter but with ->user_nicename or another user link wrongly (does site_url() already esc_url() or must be added somewhere?) – Alex Jan 9 '16 at 17:41

Here is an example of what I've done:

    $link = home_url( '/members/' . bp_core_get_username( bp_displayed_user_id() ) . '/followers/' );
    echo "<a href='". esc_attr( $link ) ."'>Followers</a>";

So maybe its home_url now, than site_url. In the echo, esc_attr gives out the $link.

Change the whole bp_core_get_username( bp_displayed_user_id() ) to whatever you need - wp_get_current_user() for example.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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