News:

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

Main Menu

Add fields to Member Summary page

Started by TonyJ, February 26, 2020, 08:14:28 PM

Previous topic - Next topic

TonyJ

Last question for a while. :-)

I've imported 300+ users into our private SMF database. I'd like to add a Mobile Number field, below Location, on the Member Summary page. The Mobile Number is already populated in the NPK_MEMBERS Table.

Where do I find the files to add the word Mobile, as well as display the member's mobile number? Themes, Sources, or both?

Thank you.
I want to die in my sleep like my Grandfather. Not kicking and screaming like his passengers!

Antechinus

Custom profile fields in admin should let you set that up.

Specifically:  Administration Center >> Features and Options >> Profile Fields

TonyJ

I tried that, but Custom Fields only pulls data from the Custom Fields Table, not the Member Table.
I want to die in my sleep like my Grandfather. Not kicking and screaming like his passengers!

Antechinus

Ah. What's the field name in that table? Have you tried dropping $context['mobile_number'] into the template?

The template would be Profile.template.php and the summary page is the first function in the template.

ETA: Well, first function in 2.0.x, but if you're running 2.1 it starts on line 153.

TonyJ

Thanks. I'm using 2.0.17.

Still trying to locate the files to insert Mobile number etc. Profile_Template doesn't seem to like me adding Mobile to the Summary page. Just doesn't appear at all. :-(
I want to die in my sleep like my Grandfather. Not kicking and screaming like his passengers!

Antechinus

That's the file that handles the summary.

Code (Profile.template.php - line 46) Select
// This template displays users details without any option to edit them.
function template_summary()
{


So if it won't show up, then the problem is how that database field is being called. What code are you trying to call it with?

Antechinus

Just had a thought. Why do you need the mobile number to be in your members table? It's a non-standard field in that table anyway.

Is there some reason why you can't just create a custom field for all members, set it to show on the summary page, and then import the relevant data to a new field in the themes table?

Just as a quick test I set one up on local. The field is defined in the custom fields table, but (for some weird reason I will refrain from asking about) the actual values for each member are stored along with their theme preferences in the themes table.

It has this structure:






id_membermediumint( 8 )1
id_themetinyint(4) unsigned1
variablevarchar(255)cust_mobile
valuetext0493278134

Which doesn't need varchar(255) for a mobile phone number,  but that was the default, so I just left it that way for a quick test.

Antechinus

Ok, if you want to do it from the members table have a look at the way this mod does similar custom fields:

https://custom.simplemachines.org/mods/index.php?mod=4001

Note that you won't need to edit all of those files if you only want to display it on the profile summary page. You should only need edits in Load.php, ManageSettings.php, Profile-Modify.php, Subs-Members.php and Profile.template.php.

If you want to support multiple languages you'd also need language strings in Modifications.english.php and corresponding files for whatever other languages you use. If you only want to support one language you can just hard code the text in the template and not worry about it.

Personally I think it would be easier to just do the required 300+ rows with database operations and not have to hack four Sources files, but it's up to you.

TonyJ

Thanks very much for your help with this.

The CSV file, that contains the 300+ members, had all info that I needed, including email address, mobile etc, so from a non PHP coder perspective, it was easier for me to import the whole file into the Members table, as I had no idea how to get the Custom Fields table to work for me. All trial and error. :-)

I'll give your mod suggestion a go and see if I can make that work.

Thanks again.
I want to die in my sleep like my Grandfather. Not kicking and screaming like his passengers!

TonyJ

Spent time looking at the files that need editing, but my experience is zilch and I'll wind up buggaring up the board.

Will try and find someone to write a Member List / Member Profile editor that will let me add the bits that I need. maybe some of the Mod sites will sell me something that does the job.

Thanks again.



Quote from: Antechinus on February 27, 2020, 03:50:58 PM
Ok, if you want to do it from the members table have a look at the way this mod does similar custom fields:

https://custom.simplemachines.org/mods/index.php?mod=4001

Note that you won't need to edit all of those files if you only want to display it on the profile summary page. You should only need edits in Load.php, ManageSettings.php, Profile-Modify.php, Subs-Members.php and Profile.template.php.

If you want to support multiple languages you'd also need language strings in Modifications.english.php and corresponding files for whatever other languages you use. If you only want to support one language you can just hard code the text in the template and not worry about it.

Personally I think it would be easier to just do the required 300+ rows with database operations and not have to hack four Sources files, but it's up to you.
I want to die in my sleep like my Grandfather. Not kicking and screaming like his passengers!

Advertisement: