SECURITY UPDATE EasyDiscuss 4.1.16 Released. Important security update and minor bug fixes 🔑


Sometimes you need to display total blog post count "outside" EasyBlog component, in a custom template position.
You can do this by using the code below. The code will query the database and will display the total published blog posts count for current logged-in user.

$user =JFactory::getUser();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = 'select count(1) as `post_count`';
$query .= ' from `#__easyblog_post` as a';
$query .= ' where a.`created_by` = ' . $user->id;
$query .= ' and a.published = ' . $db->Quote('1');
$postcount = $db->loadResult();
echo $postcount;

You can use this if you want for example to present to the current logged-in user his total blog posts count. Think about it kinda like a "notification" count. In our case scenario, we built a "My Account" custom menu where we listed some personal menu option for current logged in user. We used the above code to show post count next to "My Blog Posts" menu option.

Enjoy ! I hope you will find a good use ! :p

This section can only be seen by users with a valid subscription.
If you have a valid subscription, please login now

Your time
Stack Ideas HQ
Support is

It is currently a weekend from where we are at. Some answers may already be available on our documentation

Rest assured that we will get back to your posts as soon as the week starts!

Subscribe for product updates & promotions