Forums

Join
bbPress Support ForumsPluginsWrite last post of user

Info

Write last post of user

  1. I am working on an ajax function, and currently I write a plugin which gives the last post of the logged-in user.

    The post should be displayed using the post.php template of the current theme.

    I try to get the last post from the DB as an object, and give it to the bb_post_template() function, like written below, but that doesn't work.

    What should I do?

    I have $user = 2 as an example.

    $lastpost = $bbdb->get_results("SELECT * FROM bbpress_posts WHERE poster_id = ".$user." ORDER BY post_time desc LIMIT 0, 1");
    
    		foreach ($lastpost as $bb_post)
    		{
    			$id = $bb_post->post_id;
    			$post = bb_get_post($id);
    			if($post)
    			{
    				bb_post_template();
    			}
    		}
  2. What happens when you use this?

  3. I get just the template (post.php) without data in it.

  4. You must log in to post.