1
Koeneke
Xoops 2.3.1 - How to get addition field of users in Extended Profiles
  • 2008/11/4 20:44

  • Koeneke

  • Just popping in

  • Posts: 19

  • Since: 2008/1/30


Hello,

I'm wondering how I can get an additional field to display. I tried

$xoopsUser->getVar('additional_field');


In this case, additional_field is an array of groups...
But I don't get any output...

Can anyone point me in the right direction?

Thanks,
Koeneke

2
trabis
Re: Xoops 2.3.1 - How to get addition field of users in Extended Profiles
  • 2008/11/4 21:01

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


I´m just guessing:

$profile_handler =& xoops_getmodulehandler('profile');
$profile = $profile_handler->get($xoopsUser->getVar('uid'));
$field = $profile->getVar('additional_field');

or

$field = unserialize($profile->getVar('additional_field'));

3
Koeneke
Re: Xoops 2.3.1 - How to get addition field of users in Extended Profiles
  • 2008/11/5 14:43

  • Koeneke

  • Just popping in

  • Posts: 19

  • Since: 2008/1/30


Trabis,

Thank you very much for giving me a direction!

It should look like this to work
$profile_handler =& xoops_getmodulehandler('profile','profile');
$profile $profile_handler->get($xoopsUser->getVar('uid'));
$field $profile->getVar('additional_field');


I hope this can help other module developers...

Koeneke



4
maxxy
Re: Xoops 2.3.1 - How to get addition field of users in Extended Profiles
  • 2009/12/29 16:25

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


Can someone help me

I'm using XOOPS 2.42

I'm trying to customize my user info template

i want to display a custom field manually in my user info template (gender)

here's what i did

1. in modules/profile/userinfo.php

i add this line near the footer
$profile_handler =& xoops_getmodulehandler('profile','profile');
$profile $profile_handler->get($xoopsUser->getVar('uid')); 
$gender $profile->getVar('gender');
$xoopsTpl->assign('gender',$gender);


2. and in modules/profiles/templates/profile_userinfo.html

i use
<{$gender}>


to display the value...
i viewed my profile

and it showed the value of the gender

but when i view other user profile its showed the same value of gender like in my profile


can someone correct my code?

i found this fix for yogurt+profile
https://xoops.org/modules/newbb/viewtopic.php?post_id=302702#forumpost302702

how to fix this if i'm not using yogurt

please help

TQ

5
alfred
Re: Xoops 2.3.1 - How to get addition field of users in Extended Profiles
  • 2009/12/29 16:39

  • alfred

  • Quite a regular

  • Posts: 249

  • Since: 2005/10/29


mh, in fact, the field should be visible even without a change
Check the Permission of fields

6
maxxy
Re: Xoops 2.3.1 - How to get addition field of users in Extended Profiles
  • 2009/12/29 16:50

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


The field and value is visible but its same for all profile

7
maxxy
Re: Xoops 2.3.1 - How to get addition field of users in Extended Profiles
  • 2009/12/29 18:23

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


Solved..here's how i did it based on the fix for yogurt+profile integration by blueteen

$profile_handler =& xoops_getmodulehandler('profile','profile');
$uid intval($_GET['uid']); //get uid from url
if ($uid <= 0) { 
 if (
is_object($xoopsUser))  {//if member
        
$profile $profile_handler->get($xoopsUser->getVar('uid'));} //get uid for the connected member
        
else {
             
header('location: ' XOOPS_URL); //back to homepage - redirect wherever you want
             
exit();
             }
 }
else 
{
//$profile = $profile_handler->get($xoopsUser->getVar('uid'));  
$profile $profile_handler->get($uid);
}

//if a correct uid passed to url - eg. : index.php?uid=12
//get uid passed to url to take right data from profile

$gender $profile->getVar('gender');
$xoopsTpl->assign('gender',$gender);

Login

Who's Online

218 user(s) are online (51 user(s) are browsing Support Forums)


Members: 0


Guests: 218


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits