I apologize if this has been covered before but I couldn't find anything in my search efforts.
I have created a new custom field called NTRP ( a selection list with 2.5,3.0,3.5,4.0,4.5+ as options) and I would like two things:
1. To be able to display this in memberlist and be able to sort by it
2. Be able to search for members by NTRP
Is this possible?
Thanks in advance,
-Phil
it is possible, but will require you to recode/modify the memberlist.php and memberlist.template.php
Quote from: Kindred on April 21, 2008, 08:00:26 PM
it is possible, but will require you to recode/modify the memberlist.php and memberlist.template.php
Could you give me an idea of which sections to modify?
ahh.. the custom fields are not stored in the member table... they have their own table
now i'm really confused.. if smf_custom_fields table contains the fields, where is the relationship to the member?
??? smf_custom_fields? ???
custom fields are stored in the smf_themes table
ahh.. the actual user-selected data is stored in smf_themes.. that brings up another question... since the value is assigned to a user's member id, how can I integrate this into the memberlist?
with database queries or use a database query to add it to the user_info array
However, it looks like custom-fields is queried to be set up in the memberlist anyway... at least for search (// Can they search custom fields?)
Quote from: Kindred on April 21, 2008, 11:34:20 PM
with database queries or use a database query to add it to the user_info array
However, it looks like custom-fields is queried to be set up in the memberlist anyway... at least for search (// Can they search custom fields?)
how so? is this dependent on theme?
search is not dependent on theme
The search routine in memberlist.php will search the custom fields for the search string, assuming they are searchable
Text and Large Text fields can already be searched on the memberlist. However you would think that if you can search them they would be displayed on the memberlist. Reguardless since the core functionality is there it shouldn't be hard to extend to the other fields.
Quote from: rsw686 on April 22, 2008, 09:11:37 AM
Text and Large Text fields can already be searched on the memberlist. However you would think that if you can search them they would be displayed on the memberlist. Reguardless since the core functionality is there it shouldn't be hard to extend to the other fields.
how is it possible to search for them? I'm relatively new to PHP and I'm not sure how I would add a checkbox for my custom field to the member search
In the Profile Fields admin section you can check a box for Text and Large text to be searchable in the field properties.
Quote from: rsw686 on April 22, 2008, 09:20:44 AM
In the Profile Fields admin section you can check a box for Text and Large text to be searchable in the field properties.
ahh... im using a list so I guess I'm out of luck
You can change the can_search field in the database for that field to 1. Then in Memberlist.php find
// Can they search custom fields?
$request = $smcFunc['db_query']('', '
SELECT col_name, field_name, field_desc
FROM {db_prefix}custom_fields
WHERE active = {int:active}
' . (allowedTo('admin_forum') ? '' : ' AND private != {int:private}') . '
AND can_search = {int:can_search}
AND (field_type = {string:field_type_text} OR field_type = {string:field_type_textarea})',
array(
'active' => 1,
'can_search' => 1,
'private' => 2,
'field_type_text' => 'text',
'field_type_textarea' => 'textarea',
)
);
and replace with
// Can they search custom fields?
$request = $smcFunc['db_query']('', '
SELECT col_name, field_name, field_desc
FROM {db_prefix}custom_fields
WHERE active = {int:active}
' . (allowedTo('admin_forum') ? '' : ' AND private != {int:private}') . '
AND can_search = {int:can_search}',
array(
'active' => 1,
'can_search' => 1,
'private' => 2,
)
);
Now you can search that field. Granted it would be good to modify the profile field's admin page to show the can_search checkbox for all fields. However by changing the database value manually you can get around that. Chances are your not going to change the field properties that much anyway.
The only piece your missing is displaying the field choice on the memberlist.
thank rsw, I'll give that a try tonight!
you guys have been very helpful.. one last thing, if I wanted to replace the ICQ column in member list the with the 3 digit NTRP custom field I've made, what would I need to change?
you would need to change code in memberlist.template.php.
You would also have to draw the value of your custom field out of the database and into a useable variable/array.
Actually, IMO, the custom fields should be added in a "customfield" subset of the user_info array
Quote from: Kindred on April 22, 2008, 11:11:58 AM
you would need to change code in memberlist.template.php.
You would also have to draw the value of your custom field out of the database and into a useable variable/array.
Actually, IMO, the custom fields should be added in a "customfield" subset of the user_info array
sounds like it could be over my head.. I might have to just stick with the ability to search (which works now, thanks guys)
Were you ever able to resolve this?
There was actually another suggestion made on this not long ago where one of the developers thought it might be a good
Currently though i can't see an easy way to add custom fields to the list without decent modifications to the Memberlist.php file.
You can see where it was added to the bugtracker as a feature request. Bug #2110: Show Custom Profile Fields on Memberlist (http://dev.simplemachines.org/mantis/view.php?id=2110)