Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated

show custom Jmsocial profile fields in Kunena

6 years 2 weeks ago
Licenses:
JomSocial Active

I added this to me Kunena pages to show special fields in Kunena, feel free to use as you want:

It shows age in years, gender, link to gallery if it exists, etc.

I put this after line 56 in this file:
components/com_kunena/template/blue_eagle/html/topic/default_profile_vertical.php

ONLY TESTED IN J3 JS v3

<?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');
$user =& CFactory::getUser($authorid);
$db=JFactory::getDBO();
 
// write profile fields you want to retrieve here, find the name of the field on Jomsocial profile field area
$country = $user->getInfo('FIELD_COUNTRY');
$haller = $user->getInfo('FIELD_HALLER');
$gender = $user->getInfo('FIELD_GENDER');
$date_of_birth = $user->getInfo('FIELD_BIRTHDATE');
$condition = $user->getInfo('contition');
$sx_status = $user->getInfo('sx_status');
 
//figure out age in years
$DateOfBirth      = strtotime($date_of_birth);
$DateDifference   = time() - $DateOfBirth;
$AgeInYears       = $DateDifference /(60*60*24*365);
$AgeInYears  = floor($AgeInYears);
 
//figure out if gallery exists, if photos are in gallery, and gallery set to public or members
//0=public, 20=members, 30=friends, 40=me only
$query = "SELECT a.`creator`
from `jos_community_photos_albums` a, `jos_community_photos` b
where a.`creator` = $authorid
and a.`permissions` IN (0, 20)
and a.`id` = b.`albumid`";
$db->setQuery( $query ); 
$gallery = $db->loadResult(); 
 
//show gender and age if available
if (isset($gender, $date_of_birth)) {
echo "$gender, $AgeInYears<br />";
}
 
//show link to gallery if there is one
if ($gallery) {
echo "<a href='http://www.YOUR.DOMAIN/my-photos/$authorid-$username'>My Gallery</a><br />";
}
 
//these last 2 are specific to my page, but you can do something similar with your custom fields
//show condition and status if they exist
if ((isset($condition, $sx_status)) && ($condition!= "None")) {
echo "$condition<br />$sx_status<br />";
}
 
//show haller if it exists
if ($haller) {
echo "Haller: $haller";
}
 
?>

6 years 2 weeks ago
  • David's Avatar
  • David
  • Visitor
  • Thank you received: 0
Licenses:

Hi Adam,

Nice info for the other :) Thanks Adam :)

Warm Regards,

David

Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW