Forums

Join
bbPress Support ForumsTroubleshootingHere's how to show bbPress info inside WordPress without full integration

Info

Here's how to show bbPress info inside WordPress without full integration

  1. I need more info than "didn't work"

    Try replacing $bbdb with $wpdb

  2. I need more info than "didn't work"

    Fatal error: Call to a member function get_results() on a non-object in wordpress/wp-content/themes/mytheme/header.php on line 149 (line where I placed the code)

    Try replacing $bbdb with $wpdb

    no error but what I want is to query bbpress data base. Whenever I echo $results there is no answer.

  3. That is with bbPress 1.0 right? the object_type is for 1.0
    You get nothing using get_results because it returns an array - use get_var instead

    <?php
    global $bbdb;
    $result=$bbdb->get_var("SELECT SUM(meta_value) FROM bb_meta WHERE object_type='bb_topic' AND meta_key='views'");
    echo $result;
    ?>
  4. That is with bbPress 1.0 right? the object_type is for 1.0

    Yes, it is bb 1.06a with wp 2.7 :)

    I tried with get_var and I get the same error for get_var;

    Fatal error: Call to a member function get_var() on a non-object in....

    but then I changed $bbdb for $wpdb and it works. Why? I don't understand this.

  5. Because for some reason the bbdb object must not be created when deeply integrated under 1.0

    Must have something to do with backpress which re-uses wp functions.

  6. Ok, thanks for your help :) I'm going to try more of these queries. I find them very useful to integrate small details.

  7. This other nice trick by you doesn't work either from the wp comments template;

    global $wpdb;
    $result=$wpdb->get_var("SELECT COUNT(*) FROM bb_posts WHERE poster_id = $user_id AND post_status = 0");
    echo $result;

    No errors though. I tried replacing poster_id with wp comment_author_id but it didn't make it.

    What I was trying to do is to put the the whole count of wp comments and bbpress posts all together.

    The previous question was because I produced a hit counter that runs for both; wp and bbpress. I added the total hits of the bbpress post views plugin to the wp counterize plugin. It works but I think I did this by the hard way.

  8. Hello, so how's the code if we'd like to add posteb by... in ...
    I get the topic and forums list but'd like to show the author.
    Tried the codes at the beginning but doesnt seem to work, fatal errors :S

    thanks in advance

    ernesto

  9. edlvg you want something like
    echo "Posted by $result->topic_poster_name";

    I just realized I completely missed explaining how to get forum names via WordPress, I was telling people to use bbPress functions which is of course impossible from WordPress. Let me know if anyone still needs the help.

  10. can you please just do a step by step tutorial, it is really hard to follow and i dont know which piece of code goes where.

  11. thanks _ck_ worked beautiful, sounds quite helpful having a tutorial though, :p

  12. Well since bbpress and wordpress are using ezsql... you can find ezsql tutorial here.

    http://justinvincent.com/docs/ezsql/ez_sql_help.htm

  13. Hey guys! I can't make $result->topic_poster_name work in my 0.9.0.4 instalation.

    Is this the right function for this version?


    // REPLIES
    $query_replies="SELECT * FROM bb_posts WHERE topic_id=$topic_id AND post_id != $first_reply_id AND post_status=0 ORDER BY post_time DESC";
    $results_replies=$wpdb->get_results($query_replies);
    $replies_text = "";

    foreach ($results_replies as $result) {
    echo $result->post_text;
    echo $result->topic_poster_name;
    }

    The post_text works perfectly, but the poster_name returns me nothing. Any idea?

  14. Done!

    get_post_author($result->post_id);

    Could find in:

    http://phpxref.ftwr.co.uk/bbpress/nav.html?_functions/index.html

  15. Yes but that wouldn't work from the WordPress side.

    The correct way to do it directly would be to either use the topic table which has the topic_poster_name (not bb_posts) or to use a LEFT JOIN on the user table to fetch the user_login.

    The LEFT JOIN will also get you the display name.

    But there are several problems with your question.
    First of all, you mean Display Name, not Nice Name, unless you are trying to use it in a way I don't understand.

    Secondly 0.9 doesn't use Display Name.

    Third,
    "SELECT * FROM bb_posts WHERE topic_id=$topic_id AND post_id != $first_reply_id AND post_status=0 ORDER BY post_time DESC"

    is a very inefficient query, there's no LIMIT, you are using *
    what exactly are you trying to find?

  16. dear _ck_,
    i did as you suggested with adding
    <?php require('/local-path-to-bbpress/bb-load.php'); ?>
    to wordpress but it conflicts with wp-admin.
    any idea how to resolve this?

    http://bbpress.org/forums/topic/wordpress-integration-login#post-55751

  17. Tomwi: can you post your code for showing mentioned template

    *post title*
    Posted by: *user* in *forum*.

    or send it to me - procka@tasty.sk

    greets
    Vlado

  18. How does using $wpdb & $bbdb differs from using $results=mysql_query($query);?

  19. $wpdb and $bbdb have nice sanitizing functions and caching of results if I remember correctly
    http://codex.wordpress.org/Function_Reference/wpdb_Class
    They can also be used to retrieve table names for the respective package

  20. Thanks ! I forgot that I should check out the codex for that.

  21. @Kawauso
    I think using $wpdb & $bbdb should sanitize by them self but reading the page on codex it looks like that we need to do that explicitly. I am a lil confused. Can you please clarify?

  22. Yep, you have to sanitize yourself, the database objects presume anything they're passed has been already

  23. How exactly can I exclude some forums for showing up in this code, that generates a list of forums, or rather, HOW can i show only selected forums?

    <?php if ( $topic ) : ?>
        <h2>Forum List</h2>
        <ul>
        <?php
        global $bbdb;
        $query="SELECT * FROM bb_forums WHERE topics!=0 ORDER BY forum_order ASC LIMIT 10";
        $results=$bbdb->get_results($query);
        foreach ($results as $result) {
        echo "<li><a href='/forum.php?id=".$result->forum_id."'>".$result->forum_name."</a></li>";
        }
        ?>
        </ul>
        <?php endif; ?>
  24. SELECT * FROM bb_forums WHERE forum_id <> 1 AND forum_id <> 2 AND topics <> 0 ORDER BY forum_order ASC LIMIT 10
    Got the idea?

  25. Actually I don't. I tried your code, but its still showing the same.

  26. This works for me quite well. May be you are doing something wrong!

  27. Can someone explain how I can pull the total number of bbpress posts made and display them in wordpress theme, and also a harder one to solve, how do I get the total number of posts for a user in bbpress and display that in the users wordpress author.php?

    I've got intergration happening with shared login/registrations, tables in same DB.

    Thanks for any help :)

  28. Great Examples :) ... I think these examples would be great in the documentation for bbPress.

  29. We might be able to guilt/nag Matt into getting a proper Wiki installed here once he gets WordPress 3 out the door (but then there will be 3.0.1 and 3.0.2 the week after, so maybe 2 weeks then, lol)

  30. This is my favorite topic of all time on bbpress.org - thanks _ck_

  31. You must log in to post.