BuddyForms / BuddyForms-Members

The BuddyForms Members Component. Let your members write right out of their profiles.
https://buddyforms.com
GNU General Public License v2.0
3 stars 4 forks source link

Pagination broken if visit other users profile #7

Closed svenl77 closed 7 years ago

svenl77 commented 7 years ago

When viewing Buddypress Member profiles Posts on Profile the view previous link don't function properly. Instead of taking you to view more posts from whatever user the current user is viewing it takes you back to your profile to view your posts.

mfalk75 commented 7 years ago

Can you give me a estimate or even a snippet of code to fix it. I'm pretty good at digging into the code. I'm assuming it something in the-loop file that has to be changed but I can't figure it out how to make the url stay with the member being viewed instead of going to the logged in user.

svenl77 commented 7 years ago

If you like to dig into and create a pull request with a fix is more then welcome!

Please check line 50 $domain = is_user_logged_in() ? bp_loggedin_user_domain() : bp_displayed_user_domain();

I have changed it in the last version and I think it creates the issue. We need to add a check if is_user_logged in and view his profile or if he visit a other profile.

https://github.com/BuddyForms/BuddyForms-Members/blob/master/includes/redirect.php

Hope this is a starting point for you. Let me know if you have any question. I like to help.

mfalk75 commented 7 years ago

OK, I was able to get it to work by changing the code on line 178. Seems to work either way, logged in or out and on any profile. Not sure if it will cause trouble elsewhere though.

$result = get_bloginfo( 'url' ) . '/' . $bp->pages->members->slug . '/' . $userdata->user_nicename . '/' . $bp->current_component . '/' . $bp->current_action . '/page/' . $this_page; Changed above code to this $result = $result = $bp->displayed_user->domain . $bp->current_component . '/' . $bp->current_action . '/page/' . $this_page;

svenl77 commented 7 years ago

Hi @mfalk75,

I have just tested your fix and its working nicely. Well done! Great contribution Thank you. Much appreciated.

Cheers, Sven