Adding custom fields to profile

Started by Wiejeben, April 20, 2014, 05:15:02 PM

Previous topic - Next topic

Wiejeben

Hello SMF,

I'm currently working on a mod that requires a custom field, this field has to be on the edit on the profile and registration page.

I have figured out how to add one to the Profile-Modify.php file, which added it to the 'Forum profile' page, but I cannot figure out how to get this field required (I for now did it with HTML5), also this field must show up on the registration page.

Any ideas? This has probably been done 1 million times before but I just couldn't find any documentation for this.

Greetings,
Maarten

br360

If you want it required and on the registration page, go to Admin>>Features and Options>>Profile Fields>>

From there you can either modify and existing profile or add a new one- then you will see Show on Registration:. make sure you pick the option that says "yes, and require entry"

Wiejeben

Quote from: br360 on April 20, 2014, 06:32:24 PM
If you want it required and on the registration page, go to Admin>>Features and Options>>Profile Fields>>

From there you can either modify and existing profile or add a new one- then you will see Show on Registration:. make sure you pick the option that says "yes, and require entry"
That sounds cool for those who manage the forum. With this I meant that I'm developing a modification that requires an additional field, hardcoded.

margarett

But why can't you just use the custom fields?

Anyway, to make the field required you need to process its submission and, if empty or incorrectly filled, return to the profile modify page with an error. That's pretty much how SMF does it everywhere...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Wiejeben

Quote from: margarett on April 20, 2014, 06:38:09 PM
But why can't you just use the custom fields?

Anyway, to make the field required you need to process its submission and, if empty or incorrectly filled, return to the profile modify page with an error. That's pretty much how SMF does it everywhere...
I'm not sure if I posted this in the right board, but let me explain again.

I'm currently working on a modification, this goes with package-info.xml and another .xml that puts in my custom written HTML/PHP code. Within this I want to add my added form to the validation, I have for now as a quick fix written it manually but I wonder if there's an official way?

Like with the edit profile page I'm currently looking for a way to add this check to Profile-Modify.php. Do you know if anyone has written a good tutorial or documentation onto this? This field is being added as:

<input type="text" name="default_options[minecraft_account]" size="50" value="', !empty($context['member']['options']['minecraft_account']) ? $context['member']['options']['minecraft_account'] : '', '" />

margarett

A suggestion: don't use that field name. It might work (probably does) but it's messy. Use something like name="minecraft_account" (or even shorter!)

Now I understand what you mean. I'm sorry, I honestly don't know how to achieve that. The profile stuff is totally different from what I know...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Wiejeben

Ah well, if I use another name I would have to edit a lot more rows at both the registration and the profile edit.

Wiejeben

BUMP.

I cannot find any mod that has an input field that is both required and on both the registration and on the profile settings page. I have figured to set this up myself using default_options[minecraft_account] as the name but cannot get it required on the profile settings page.

Advertisement: