News:

Wondering if this will always be free?  See why free is better.

Main Menu

Modify mlist to include custom field

Started by thunderchld, January 31, 2018, 11:31:55 AM

Previous topic - Next topic

pepa

Quote from: Sir Osis of Liver on May 01, 2018, 07:25:16 PM
Think I did this for someone not long ago, wasn't that difficult.  You just want to add a couple of columns to memberlist for custom profile fields?

Hi Sir Osis ... if this is easy and you have already helped another are you able to assist me?

If, as you say, it's easy to merely display a few more custom profile fields on the member list, then I presume it would also be easy to have these display also on the results of searches on the member list ... the fields are searchable in their initial setup and they do display next to the search box, it's just that they don't display in the results.  Also it would be useful if the Actual Name could be displayed but only for Admins - although I could live without that feature.

I'm using SMF 2.0.15 with responsive curve 1.0.0

Sir Osis of Liver

IIRC, forum owner just wanted to display custom field in memberlist.  It was sortable, but not searchable.  Will see if I can find the topic.

Ok, it's here.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

Thanks Sir Osis : )  ... will have a look at that when I have some time

pepa

Hi Sir Osis, just had a quick look at that thread but it doesn't seem to be for a Custom Profile Field?

Sir Osis of Liver

No, it was for last login, but should be able to use it for custom field.  Will tinker with it a bit.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

Quote from: Sir Osis of Liver on May 03, 2018, 12:27:27 AM
No, it was for last login, but should be able to use it for custom field.  Will tinker with it a bit.

Hi Sir Osis, really don't want to appear pushy and have genuinely appreciated your help in the past.  I'm getting rather desperate around this issue and wondering how the tinkering is coming along.  No problem if you haven't had the time or can't help with this at all, would completely understand, thanks for everything you do in this community : )

Sir Osis of Liver

Sorry, haven't had time to do much with this.  It's not simple, and afaik there's no mod that does what you want.  Don't have it in front of me, but iirc what it basically involves is adding custom fields, which are in smf_themes table, to $members array in Memberlist.php.  Will take another look soon as I have time.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

Thanks Sir Osis .. I didn't think it would be easy as it's been requested by so many over time and no-one has responded.  Would be fantastic if you can get across this, but as I said above ... perfectly understand if you just can't find the time, life is busy!

Sir Osis of Liver

#28
Ok, sorry it took so long to get to this, it actually is pretty easy.  You have to create a new column for custom field as in the code I linked above, but instead of this -



<td class="windowbg lefttext">', $member['last_login'], '</td>';



you use this -



<td class="windowbg lefttext">', $member['options']['cust_city'], '</td>';



In this case, cust_city is the field in smf_themes table that contains the user's city.  All of the custom fields are loaded into the $member['options'] array, so you can add whichever you want, space permitting.  You can get the field names from the table.

It doesn't sort, working on that.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

Thanks so much again for your help Sir Osis, I'm taking a 4 day break and will have a look at this when I get back ... always very much indebted to you for your help : )

pepa

Quote from: Sir Osis of Liver on May 17, 2018, 01:04:24 AM
Ok, sorry it took so long to get to this, it actually is pretty easy.  You have to create a new column for custom field as in the code I linked above, but instead of this -



<td class="windowbg lefttext">', $member['last_login'], '</td>';



you use this -



<td class="windowbg lefttext">', $member['options']['cust_city'], '</td>';



In this case, cust_city is the field in smf_themes table that contains the user's city.  All of the custom fields are loaded into the $member['options'] array, so you can add whichever you want, space permitting.  You can get the field names from the table.

It doesn't sort, working on that.

OK, just had a quick look before taking the break ...a very dumb question, I just took a look at the smf_themes table using PHPMyadmin ... but that doesn't show any fields names.  Where/how do I see the field names?

Sir Osis of Liver

Field names are in 'variable' column.  When you create a custom field, it adds field name as 'variable', user input as 'value'.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

Quote from: Sir Osis of Liver on May 17, 2018, 06:39:58 PM
Field names are in 'variable' column.  When you create a custom field, it adds field name as 'variable', user input as 'value'.

Hmmm, not sure ... I'm not seeing anything like that in the smf_themes table variable column ... but I do see all the field names in the smf_custom_fields table in the col_name column?

Sir Osis of Liver

#33
Haven't been able to get the mlist column to sort, but it displays correctly.  Custom fields field names and values are in two tables, smf_custom_fields and smf_themes, and are pulled from one or the other for different purposes.  Why?   Was getting some help in another thread before I got sidetracked, let's see if I can find it ...

Here it is - https://www.simplemachines.org/community/index.php?topic=560408.0
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Advertisement: