Advertisement:

Author Topic: Modify mlist to include custom field  (Read 3160 times)

Offline pepa

  • Jr. Member
  • **
  • Posts: 192
Re: Modify mlist to include custom field
« Reply #20 on: May 02, 2018, 10:57:28 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

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 7,941
  • 'Tis the gift to be simple (duh)
Re: Modify mlist to include custom field
« Reply #21 on: May 02, 2018, 11:04:03 PM »
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.

Offline pepa

  • Jr. Member
  • **
  • Posts: 192
Re: Modify mlist to include custom field
« Reply #22 on: May 03, 2018, 12:04:24 AM »
Thanks Sir Osis : )  ... will have a look at that when I have some time

Offline pepa

  • Jr. Member
  • **
  • Posts: 192
Re: Modify mlist to include custom field
« Reply #23 on: May 03, 2018, 12:25:44 AM »
Hi Sir Osis, just had a quick look at that thread but it doesn't seem to be for a Custom Profile Field?

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 7,941
  • 'Tis the gift to be simple (duh)
Re: Modify mlist to include custom field
« Reply #24 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.

Offline pepa

  • Jr. Member
  • **
  • Posts: 192
Re: Modify mlist to include custom field
« Reply #25 on: May 11, 2018, 07:17:45 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 : )

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 7,941
  • 'Tis the gift to be simple (duh)
Re: Modify mlist to include custom field
« Reply #26 on: May 11, 2018, 11:00:33 PM »
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.
 

Offline pepa

  • Jr. Member
  • **
  • Posts: 192
Re: Modify mlist to include custom field
« Reply #27 on: May 12, 2018, 03:03:03 AM »
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!

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 7,941
  • 'Tis the gift to be simple (duh)
Re: Modify mlist to include custom field
« Reply #28 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 -

Code: [Select]

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


 you use this -

Code: [Select]

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

« Last Edit: May 17, 2018, 01:17:04 AM by Sir Osis of Liver »

Offline pepa

  • Jr. Member
  • **
  • Posts: 192
Re: Modify mlist to include custom field
« Reply #29 on: May 17, 2018, 03:53:49 AM »
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 : )

Offline pepa

  • Jr. Member
  • **
  • Posts: 192
Re: Modify mlist to include custom field
« Reply #30 on: May 17, 2018, 08:17:37 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 -

Code: [Select]

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


 you use this -

Code: [Select]

<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?

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 7,941
  • 'Tis the gift to be simple (duh)
Re: Modify mlist to include custom field
« Reply #31 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'.

Offline pepa

  • Jr. Member
  • **
  • Posts: 192
Re: Modify mlist to include custom field
« Reply #32 on: May 27, 2018, 04:55:24 AM »
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?

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 7,941
  • 'Tis the gift to be simple (duh)
Re: Modify mlist to include custom field
« Reply #33 on: May 27, 2018, 05:19:41 PM »
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
« Last Edit: May 27, 2018, 05:40:42 PM by Sir Osis of Liver »