Custom profile fields in user lists

Started by sunlight, June 12, 2006, 09:07:22 AM

Previous topic - Next topic

sunlight

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 ?


winrules

#1
In memberlist.php on RC2
Find:

if (!loadMemberContext($member))
continue;

Replace:

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.


winrules
SMF Developer
               
My Mods
Please do not PM me for support.


littleone

Why dont you just use the mod that someone has already written up for this?

winrules

Quote from: littleone on June 12, 2006, 07:16:00 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.


littleone

oh ok, I didnt realize that they want those fields to show in the memberlist.

sunlight

Quote from: winrules on June 12, 2006, 08:23:53 PM
Quote from: littleone on June 12, 2006, 07:16:00 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).

we are waiting for you :)

sunlight

Quote from: winrules on June 12, 2006, 06:00:00 PM
[...]
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

ira42

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

sunlight

Quote from: sunlight on July 25, 2006, 06:35:49 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)

sunlight

still working on it but with no success
anyone could help please?

thanks

jamesk

Quote8: 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...

jamesk

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:

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


Advertisement: