Advertisement:

Author Topic: Custom profile fields in user lists  (Read 8163 times)

Offline sunlight

  • Semi-Newbie
  • *
  • Posts: 16
Custom profile fields in user lists
« on: June 12, 2006, 09:07:22 AM »
Hi
I'd like to show 2 custom profile fields in user list.
I already made changes to table.. but I tried to show these 2 fields with no success.

i tried to call modified function DisplayRealName()
or to simply add something like
 echo '<TD>' .$message['member']['options']['field_name'] .'

anyone could please help me ?


Offline winrules

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,085
  • Gender: Male
Re: Custom profile fields in user lists
« Reply #1 on: June 12, 2006, 06:00:00 PM »
In memberlist.php on RC2
Find:
Code: [Select]
if (!loadMemberContext($member))
continue;
Replace:
Code: [Select]
if (!loadMemberContext($member))
continue;

global $context, $sourcedir, $user_profile;
require_once($sourcedir . '/Profile.php');
$context['user']['is_owner'] = 0;
$user_profile[$member]['ID_THEME'] = 1;
loadThemeOptions($member);
$context['members'][$member]['options'] = isset($context['member']['options']) ? $context['member']['options'] : array();
And then you can use $member['options']['field_name'] to display the field. Being able to search and sort is an entirely different thing however.
« Last Edit: June 12, 2006, 08:23:02 PM by winrules »
winrules
SMF Developer
               My Mods
Please do not PM me for support.


Offline littleone

  • Full Member
  • ***
  • Posts: 482
  • Gender: Male
Re: Custom profile fields in user lists
« Reply #2 on: June 12, 2006, 07:16:00 PM »
Why dont you just use the mod that someone has already written up for this?

Offline winrules

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,085
  • Gender: Male
Re: Custom profile fields in user lists
« Reply #3 on: June 12, 2006, 08:23:53 PM »
Why dont you just use the mod that someone has already written up for this?
I'm assuming that you're talking about my Custom Profile Field Mod. You can't currently display fields on the memberlist with my mod (but it's comming soon).
winrules
SMF Developer
               My Mods
Please do not PM me for support.


Offline littleone

  • Full Member
  • ***
  • Posts: 482
  • Gender: Male
Re: Custom profile fields in user lists
« Reply #4 on: June 13, 2006, 01:18:14 PM »
oh ok, I didnt realize that they want those fields to show in the memberlist.

Offline sunlight

  • Semi-Newbie
  • *
  • Posts: 16
Re: Custom profile fields in user lists
« Reply #5 on: July 19, 2006, 06:29:50 AM »
Why dont you just use the mod that someone has already written up for this?
I'm assuming that you're talking about my Custom Profile Field Mod. You can't currently display fields on the memberlist with my mod (but it's comming soon).

we are waiting for you :)

Offline sunlight

  • Semi-Newbie
  • *
  • Posts: 16
Re: Custom profile fields in user lists
« Reply #6 on: July 25, 2006, 06:35:49 AM »
[...]
And then you can use $member['options']['field_name'] to display the field. Being able to search and sort is an entirely different thing however.

Good, nice work, now it shows fields in members list but I have this error in error log for each field I added when showing user list:

8: Undefined index: CP3
File: /home/criferrara-it/www/smf/Themes/default/Memberlist.template.php (eval?)
Linea: 126

what does this mean ? it cannot find declaration for variable "CP3" ?
may you help me solving error ?

thanks

Offline ira42

  • Semi-Newbie
  • *
  • Posts: 16
Re: Custom profile fields in user lists
« Reply #7 on: September 26, 2006, 07:02:58 PM »
Winrules, first off, this is an amazing mod, tx!

Second, I'm trying to modify the registration form to pass certain custom fields to the admin e-mail once a user activates their account. I have a checkbox on the reg form, and if it's checked I want the admin to get that info in their mail.

Poking around, it looks like I would need to add code similar to the code above, to my Subs-Members.php file, but can't get the syntax right.  Any idea how to call the results and pass to the sendmail functions?

Thanks in advance,

Ira

Offline sunlight

  • Semi-Newbie
  • *
  • Posts: 16
Re: Custom profile fields in user lists
« Reply #8 on: October 06, 2006, 05:04:52 AM »
Good, nice work, now it shows fields in members list but I have this error in error log for each field I added when showing user list:

8: Undefined index: CP3
File: /home/criferrara-it/www/smf/Themes/default/Memberlist.template.php (eval?)
Linea: 126


still have this problem
one of this error for each additional field added.

and a general:

8: Undefined variable: member
File: /home/criferrara-it/www/smf/Themes/default/Memberlist.template.php (eval?)
Linea: 110

where member should be the original array.

are they variable definition error ?
how to solve it ?
(however page is displayed correctly)

Offline sunlight

  • Semi-Newbie
  • *
  • Posts: 16
Re: Custom profile fields in user lists
« Reply #9 on: November 27, 2006, 05:09:29 AM »
still working on it but with no success
anyone could help please?

thanks

Offline jamesk

  • Full Member
  • ***
  • Posts: 411
Re: Custom profile fields in user lists
« Reply #10 on: September 21, 2007, 10:32:53 AM »
Quote
8: Undefined variable: member
File: /home/criferrara-it/www/smf/Themes/default/Memberlist.template.php (eval?)
Linea: 110

I, too, am having the exact same problem and can't figure it out.  The funny thing is that I have two servers (one that I use as a testing platform) and only one shows the errors.  The memberlist.php and Memberlist.template.php are exactly the same...

Using ver. 1.1.3 with custom profile mod...

Offline jamesk

  • Full Member
  • ***
  • Posts: 411
Re: Custom profile fields in user lists
« Reply #11 on: September 21, 2007, 04:08:44 PM »
Being new to PHP, I overlooked a basic error.  The variable (CP1) in my case was never set for some members resulting in that error.  On the test server, there was not enough members/data to reproduce the error...

So, sunlight, you probably can just put an isset() or !empty() in the Memberlist.template.php in the foreach loop where it displays member's data.  I'm sure there's a more elegant, correct way but this worked for me:

Code: [Select]
<td class="windowbg2">', empty($member['options']['CP1']) ? '' : $member['options']['CP1'] , '</td>