Support Forum

buddypress profile link

SH Shibu
Shibu
Member

Hi

I’m using the ‘display profile information in: Buddypress profile’ option.

The page it redirects me to is ‘members/name/profile’ and it works fine but I wish I could make it go to ‘members/name’ instead. I hope someone can help me out.

14 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

Sorry for the delay. I was hoping @mr-papa would be able to visit the forums last night as he is the author of the both the BuddyPress integration plugin and our profile options.

I can look at the BuddyPress plugin code to see if I can determine how that might be changed but you might want to try changing the standard SP profile options first. As you will see, you can select a different url to be sent to – but you do then need to supply the query var that is going to pass along the ID to be displayed. (See the popup help for more information).

Will this not do what you want?

SH Shibu
Shibu
Member

Thanks for the reply.

I’ve tried to use a different url but I’m not sure what the query variable is called. I was hoping I could set-up a user friendly url. I can’t seem to find where the profile url is defined in the code. I don’t mind changing the core files if necessary.

YS Yellow Swordfish
Yellow Swordfish
Member

Do you not see a url when you run this page you want to display? If so is there no query variable being used? How does it know – if not – which user to display data for?

SH Shibu
Shibu
Member

Well, buddypress uses custom slugs like members, profile and activity so I can’t really see the dynamic url structure.

YS Yellow Swordfish
Yellow Swordfish
Member

What I meant by the question though was – if you run this url that you want to display the profile for a specific user is there a query variable showing up in the browsers address bar…

SH Shibu
Shibu
Member

No, there is no query variable showing up in the address bar.

YS Yellow Swordfish
Yellow Swordfish
Member

I see, Well no matter what you do, somehow you have to be able to inform the profile display routines just who it is you want to show – which means it has to be informed of the user ID. if there is no query variable then that suggests it is done with a POST operation and you might need to construct a special form for the process.

I will talk to my colleagues buI think more detail on the target of this url and how it operates and what yt does will be needed

MP Mr Papa
Mr Papa
Member

no query arg needed… buddypress just takes you to the profile for the ‘name’ specified in the url…  however, they set the url with the profile at the end…  buddypress does have an option to use the nicename or the user login…  but it does require the profile at the end as near as I can tell…

I am unaware of a way to change that in buddypress, but perhaps with a hook its possible – sorry dont have copy to look at tonight…

if there is a filter and you can force buddypress to change the profile url structure, then we also offer a filter so you can make a corresponding change…

SH Shibu
Shibu
Member

The url has to be defined somewhere in the sp-plugin right? If I could just remove the last slug name (profile) or change it to activity I would be satisfied. Does anyone know where this code is located?

MP Mr Papa
Mr Papa
Member

If you change just the url on the sp side, how will buddypress sort out the url??

As I said, we have a facility already in place for you to adjust the url…  its a standard wp filter called sph_buddypress_profile….  just set up a standard wp filter on it and you can adjust however you like…  just remember, buddypress has to understand the url… 

if you dont know how to use standard wp filters, just let us know and we can walk you through it…

SH Shibu
Shibu
Member

I’m sorry. I’m a beginner when it comes to php.

I have this filter in place

function bp_profile_url() {return 'http://test';}
add_filter('sph_buddypress_profile', 'bp_profile_url');

How do I get the username in accordance to the sp id?

YS Yellow Swordfish
Yellow Swordfish
Member

Well I am sure @mr-papa wll correct me if I am wrong or if I am missing something here but there can be many ways of determining the user name dependent upon where it is being called from. The current user is one,. The user who made a specific post is another. Then there might be the members list where it is simply the user that is selected.

Are these the sort of user name ‘sources’ that you mean?

SH Shibu
Shibu
Member

Yes those are the sources I mean.

This is what I have so far

add_filter('sph_buddypress_profile', 'bp_profile_url');
function bp_profile_url() {
$userid = 1;
$user = new WP_User($userid);
$username = bp_is_username_compatibility_mode() ? $user->user_login : $user->user_nicename;
if (strstr($username, ' ')) {$username = $user->user_nicename;} else {$username = urlencode($username);}
return SFSITEURL.user_trailingslashit(BP_MEMBERS_SLUG.'/'.str_replace(' ', '', $username));}
MP Mr Papa
Mr Papa
Member

sorry, you have lost me…

back in post #1, you said it was all working and you just wanted to remove the /profile from the end…  so know you have lost me as to what you are doing…  to simply remove the /profile from the end as requested in first post, something like this:

add_filter('sph_buddypress_profile', 'my_sp_bp_profile_url');
function my_sp_bp_profile_url($url) {
    $url = str_replace('/profile/', '/', $url);
    return $url;
}

but it appears you are trying to do way more than introduced in the first post…  if so, could you elaborate further?  are you trying to redo bp profile url?  or just ours?