×
Blue Eagle (1.5.0) for K5.1 is released (20 Jul 2018)

Please update the Kunena Blue Eagle to 1.5.0 if you use Kunena 5.1.
We made several bug fixes and improvements. Also Blue Eagle has now all the features from Crypsis.
Download: www.kunena.org/download/templates/category/blue-eagle-5

Question How do i get the post author id?

More
2 years 8 months ago #1 by Baze
Hi guys,

i'm using this code to show JomSocial custom fields under the Kunena avatar in the forum:
$authorid = $this->profile->userid;
$username = $this->profile->username;
$jspath = JPATH_BASE.DS.'components'.DS.'com_community';
include_once($jspath.DS.'libraries'.DS.'core.php');
$cuser =& CFactory::getUser($authorid);
$db=JFactory::getDBO();
$bike = $cuser->getInfo('FIELD_MODEL');
 
echo "Bike: $bike";

i have this in /components/com_kunena/template/mytemplate/layouts/user/profile/default.php

So in kunena under the avatar on each post i see the "Bike:" label but the data on all posts is from the logged in user, not the user who wrote the post. Any idea how can i get the current author and to show the custom field for him?

Using JomSocial 4.x, Kunena 4.0.7

thanks

Please Log in or Create an account to join the conversation.

More
2 years 8 months ago #2 by Baze
OK, got it myself.

I you want to show JomSocial custom fields under Kunenas user avatar, here's the code:
<?php
 
//get important Joomla data and connections
$authorid = $this->profile->userid;
$username = $this->profile->username;
$jspath = JPATH_BASE.DS.'components'.DS.'com_community';
include_once($jspath.DS.'libraries'.DS.'core.php');
$buser =& CFactory::getUser($authorid);
$baze = $buser->getInfo('FIELD_yourfield');
 
if ($baze) {
echo "Label: $baze";
}
 
?>

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to add attachements.
  • Not Allowed: to edit your message.
Time to create page: 0.089 seconds