Forums

Join
bbPress Support ForumsThemesget favorites list

Info

get favorites list

  1. Hi,
    Is there a way of getting a user's favorites to display without on a forum page other than /profile/#/favorite ?
    I've looked at the code but I don't want to dig too deeply into it as I'm sure it will change a lot during the next year.
    Basically what I want to do is create a unified profile page, which has been possible with everything except favorites.
    See http://www.surrealroad.com/forum/1 if this doesn't make sense

  2. Has anyone figer this out?

  3. Looking in "favourites.php", right in the root of BBpress (so its not hidden), i found this:

    $topics = get_user_favorites( $user->ID, true );

    I'd use that and output the array, but then again, i'd not have bumped 2 different 2 year old threads, let alone doing it before looking in the file cunningly named Favourites.php ;-)

  4. Thanks, but how can i put this in my template?

  5. Two ways:

    1) It's an array, so just cycle through it and output the bits you want, this will allow you to style it as you please. If you're unsure of what it returns use: print_r($topics);

    2) Alternatively, you could just copy all 3 lines from the Favourites.php file:

    $topics = get_user_favorites( $user->ID, true );
    $favorites_total = isset($user->favorites) ? count(explode(',', $user->favorites)) : 0;
    bb_load_template( 'favorites.php', array('favorites_total') );

    This will output the favourites in the way you've described in your template folder.

    ==========================================

    At the end of the day, BBpress has a number of issues, but if it can already do something, all you really need to do is copy and paste the code :)

  6. Sorry, a bit of a PHP Noob, if I insert the following code in my template:

    $topics = get_user_favorites( $user->ID, true );
    $favorites_total = isset($user->favorites) ? count(explode(',', $user->favorites)) : 0;
    bb_load_template( 'favorites.php', array('favorites_total') );

    I get an error

  7. What error do you get mate?

  8. Was that snippet of code wrapped in <?php tags ?>?

    <?php
    	$topics = get_user_favorites( $user->ID, true );
    	$favorites_total = isset($user->favorites) ? count(explode(',', $user->favorites)) : 0;
    	bb_load_template( 'favorites.php', array('favorites_total') );
    ?>
  9. Nope didn't work, i got the entire website loading serveral times in my sidebar where i put the following code:

    <?php
    $topics = get_user_favorites( $user->ID, true );
    $favorites_total = isset($user->favorites) ? count(explode(',', $user->favorites)) : 0;
    bb_load_template( 'favorites.php', array('favorites_total') );
    ?>

  10. What error do you get mate?

    :)

  11. Like i said, i got the entire website loading serveral times in my sidebar where i put the code.

  12. The entire website?
    So it's going in an infinte loop?

    Please, be less specific, don't post any code, oooh and don't include a screenshot. Guessing is a really worth while use of my time :)

  13. You must log in to post.