• Resolved SJS719

    (@sjs719)


    Thanks for the great plugin! I just have one issue I cannot resolve…

    I am trying to echo a list of the users favorite posts on their BuddyPress profile page using the functions provided at https://favoriteposts.com/
    get_user_favorites_list & the_user_favorites_list.

    But the logged in users favorites are displayed on EVERYONE’S profile page instead of their own favorites being displayed. So each logged in user see’s their own favorites list on all of the other members pages instead of seeing that members own favorites. I’m guessing it has something to do with the $user_id parameter, but I have tried passing multiple values including null, and the “get current user id” functions provided by WP and BP but it always results the same.

    How can I display each users favorite list on their own BP profile page which can be viewed by other members?

    Thanks.

    https://www.ads-software.com/plugins/favorites/

Viewing 6 replies - 1 through 6 (of 6 total)
  • George

    (@chainkiller)

    You have to pass the id of the user which the profile belongs to.

    If you have the id 3 and go to the profile of the user with id 6 the function needs to have the id 6, get current user id gets your id (3).

    I don’t use buddypress but this might work bp_displayed_user_id()
    https://codex.buddypress.org/developer/playing-with-the-users-id-in-different-contexts/

    $u_id = bp_displayed_user_id();
    the_user_favorites_list($u_id, null, true);
    Thread Starter SJS719

    (@sjs719)

    Hey George,

    Thanks for the reply, but there seems to be something fundamentally wrong with this plugin. Even if I use a specific user ID such as 11 it still returns the favorites list of the logged in user. So the user sees their own favorites on everyone else’s page even if I set a specific user ID.

    What is more strange is that the correct favorites actually DO appear for a second when the page loads but as the page continues to load it reverts back to the logged in users favorites list. And if a user doesn’t have any favorites it displays a random blog post name for a second before being replaced by the logged in user’s favs list. Very strange…

    Oh well. Good idea for a plugin, just not quite there yet.

    George

    (@chainkiller)

    Yes, i noticed too, must be a bug.

    You can use the get_user_favorites() function to get the post ids and loop through them.

    $user_id = bp_displayed_user_id();
    $post_ids = get_user_favorites($user_id);
    
        echo '<ul>';
    	foreach($post_ids as $post_id){
    		echo '<li><a href="' . get_the_permalink($post_id) . '">' . get_the_title($post_id) . '</a><span style="float:right;">'.get_favorites_button($post_id).'</span></li>';
    	}
    	echo '</ul>';
    Thread Starter SJS719

    (@sjs719)

    Thanks for the help George but I just went ahead and switched to another plugin which is a little more established and stable. If you continue to struggle with this plugin I would recommend WP Favorite Posts: https://www.ads-software.com/plugins/wp-favorite-posts/

    Plugin Author Kyle Phillips

    (@kylephillips)

    For anyone else having this problem, it should be resolved in v1.2.2.

    The issue was a javascript / page cache issue in which lists were being replaced with the current user’s list on load regardless of the user specified in the function.

    I am also facing this javascript/page cache issue on BuddyPress Members profile. But I am using v1.2.2

    Thanks ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Favorites List Doesn't Display Per Member’ is closed to new replies.