Simple Machines Community Forum

SMF Development => Bug Reports => Topic started by: CraftyLion on January 04, 2025, 06:25:48 AM

Title: Remove additional information section on registration form
Post by: CraftyLion on January 04, 2025, 06:25:48 AM
I hope this hasn't been asked before but how do I remove the Additional Information section on the registration form?
Title: Re: Remove additional information section on registration form
Post by: Aleksi "Lex" Kilpinen on January 04, 2025, 06:38:07 AM
Admin -> Configuration -> Features and Options -> Profile Fields

Click "Modify" for the field you want to remove from registration, and find the option "Show on Registration".
Title: Re: Remove additional information section on registration form
Post by: CraftyLion on January 04, 2025, 06:45:33 AM
All the custom fields I've added to the registration form are required by the applicant yet the Additional Information section still remains (and is empty).
Title: Re: Remove additional information section on registration form
Post by: Aleksi "Lex" Kilpinen on January 04, 2025, 06:49:33 AM
Hmm, didn't check or test this live - but I would have assumed, that the section should disappear if empty.
The relevant file is Register.template.php, found here https://github.com/SimpleMachines/SMF/blob/release-2.1/Themes/default/Register.template.php and I think this should mean that it's not shown if there's nothing to ask

// If we have either of these, show the extra group.
if (!empty($context['profile_fields']) || !empty($context['custom_fields']))
echo '
<div class="title_bar">
<h3 class="titlebg">', $txt['additional_information'], '</h3>
</div>
<div class="roundframe noup">
<fieldset>
<dl class="register_form" id="custom_group">';

Title: Re: Remove additional information section on registration form
Post by: CraftyLion on January 04, 2025, 03:40:26 PM
Yet this is my registration form - https://lionsden.craftylion.com/index.php?action=signup
Title: Re: Remove additional information section on registration form
Post by: Sir Osis of Liver on January 04, 2025, 04:00:51 PM
In 2.1.4 Curve2, Additional Information displays Gender profile field by default.  If Gender is disabled, Additional Information is not displayed.  Same for custom profile fields, Additional Information is only displayed if one or more fields are active.  Maybe a theme issue.  Which theme are you using?
Title: Re: Remove additional information section on registration form
Post by: Aleksi "Lex" Kilpinen on January 04, 2025, 04:06:35 PM
I'm fairly sure the custom "Please select your country" is somehow involved, it's out of place, it seems to be slightly broken, it's probably added in a way that broke the logic somehow - It really should actually be below the "Additional information" header, and the header should be there too., or it should be higher up where you see the Gender selection as well.
Title: Re: Remove additional information section on registration form
Post by: Sir Osis of Liver on January 04, 2025, 04:12:44 PM
Gender should be below Additional Information.  What does it look like in Curve2?
Title: Re: Remove additional information section on registration form
Post by: Aleksi "Lex" Kilpinen on January 04, 2025, 04:14:10 PM
Quote from: Sir Osis of Liver on January 04, 2025, 04:12:44 PMGender should be below Additional Information.
Not necessarily, it depends on if it is optional or required.
Title: Re: Remove additional information section on registration form
Post by: Sir Osis of Liver on January 04, 2025, 04:22:07 PM
Ok, yes.  But if you require both Gender and custom field, they're both displayed above Additional Information, and the heading remains, same as in OP's registration form -

https://www.thekrashsite.com/smf21core/index.php?action=signup

I think that's a bug.

Title: Re: Remove additional information section on registration form
Post by: Aleksi "Lex" Kilpinen on January 04, 2025, 04:24:54 PM
Then we may have logic error somewhere, as I understand it the Addition Information header should only be there when there is something optional presented.

E: Moved to bugs for further investigation.
Title: Re: Remove additional information section on registration form
Post by: Sir Osis of Liver on January 04, 2025, 04:29:40 PM

// If we have either of these, show the extra group.
if (!empty($context['profile_fields']) || !empty($context['custom_fields']) && empty($context['custom_fields_required']))
echo '
<div class="title_bar">
<h3 class="titlebg">', $txt['additional_information'], '</h3>
</div>
<div class="roundframe noup">
<fieldset>
<dl class="register_form" id="custom_group">';



Well, that almost works.

Title: Re: Remove additional information section on registration form
Post by: Sir Osis of Liver on January 04, 2025, 04:45:07 PM
Oddly, it only happens if both fields are required.  If one is and the other isn't, they're displayed correctly.
Title: Re: Remove additional information section on registration form
Post by: CraftyLion on January 05, 2025, 03:16:58 PM
Quote from: Sir Osis of Liver on January 04, 2025, 04:00:51 PMIn 2.1.4 Curve2, Additional Information displays Gender profile field by default.  If Gender is disabled, Additional Information is not displayed.  Same for custom profile fields, Additional Information is only displayed if one or more fields are active.  Maybe a theme issue.  Which theme are you using?


I'm using the default Curve2 theme using Curve2 Color Changer mod. Because I'm intending on running a database for voice-over actors, I need the Gender field to be required duration registration.
Title: Re: Remove additional information section on registration form
Post by: Sir Osis of Liver on January 05, 2025, 09:30:55 PM
It's not a theme issue, it's a bug.  I can give you a code hack to fix it just for your forum, but haven't been able to get register template to do it right.  Part of the problem seems to be that gender is not a custom field, which confuses the logic.
Title: Re: Remove additional information section on registration form
Post by: Arantor on January 06, 2025, 02:53:56 AM
Gender used to be not a custom field but the 2.1 install/upgrade creates it as such.
Title: Re: Remove additional information section on registration form
Post by: Sir Osis of Liver on January 06, 2025, 11:33:25 AM
Then it's just a problem with the logic.  Will have another go tonight.
Title: Re: Remove additional information section on registration form
Post by: Sir Osis of Liver on January 07, 2025, 05:27:05 PM
  >:(  Can't make this work correctly.  It should work as written -


    // If we have either of these, show the extra group.
    if (!empty($context['profile_fields']) || !empty($context['custom_fields']))
        echo '
            <div class="title_bar">
                <h3 class="titlebg">', $txt['additional_information'], '</h3>
            </div>
            <div class="roundframe noup">
                <fieldset>
                    <dl class="register_form" id="custom_group">';


But it doesn't because $context['profile_fields'] is not empty when there are no fields to display under Additional Information. 

Title: Re: Remove additional information section on registration form
Post by: live627 on January 07, 2025, 09:58:40 PM
Quote from: Sir Osis of Liver on January 04, 2025, 04:29:40 PM
// If we have either of these, show the extra group.
if (!empty($context['profile_fields']) || !empty($context['custom_fields']) && empty($context['custom_fields_required']))
echo '
<div class="title_bar">
<h3 class="titlebg">', $txt['additional_information'], '</h3>
</div>
<div class="roundframe noup">
<fieldset>
<dl class="register_form" id="custom_group">';



Well, that almost works.


We need to do the same with the cclosing tags, too.

// If we have either of these, close the list like a proper gent.
if (!empty($context['profile_fields']) || !empty($context['custom_fields']) && empty($context['custom_fields_required']))
echo '
</dl>
</fieldset>
</div><!-- .roundframe -->';
Title: Re: Remove additional information section on registration form
Post by: Sir Osis of Liver on January 08, 2025, 11:44:23 AM
Works if all custom fields are required, or all fields are not required, but doesn't work if there are required and unrequired fields.  Additional Information is not displayed.

Quote from: Sir Osis of Liver on January 07, 2025, 05:27:05 PMBut it doesn't because $context['profile_fields'] is not empty when there are no fields to display under Additional Information.