Adding custom fields in any position on form

Discussion in 'Customization & add-ons' started by dereck_j2, Jan 31, 2007.

  1. dereck_j2

    dereck_j2 Member

    Joined:
    Aug 22, 2006
    Messages:
    42
    Hi All,

    I had a ticket with the helpdesk to advise on positioning custom data fields in the "profile.html" form. Alex and his team were of great help and helped solve the problem I was having. This is what I did.

    1.a. Use the control panel to add custom fields.
    1.b. Visibility of field, make "Don't display" in Signup or Profile.

    2.a Open "profile.php" found in the aMember directory.
    2.b. find the line

    $maf = array();
    foreach ($member_additional_fields as $f){
    $maf[$f['name']] = $f;
    // Set empty values for all fields that were not submited.
    // Need to do this to get validation functions working for radio buttons.
    if(!$vars[$f[name]]) $vars[$f[name]] = '';
    }


    2.c. Edit the code in the following way. If you are adding more than one custom field.

    After "$maf = array();"

    Add your custom fields useing the format below:

    $addfields = array('company_name', 'telephone_no', 'mobile_no'); foreach ($member_additional_fields as $f){
    if (in_array($f['name'], $addfields)) $f['display_profile'] = 1;
    $maf[$f['name']] = $f;

    // Set empty values for all fields that were not submited.
    // Need to do this to get validation functions working for radio buttons.
    if(!$vars[$f[name]]) $vars[$f[name]] = '';
    }


    2.d. Save the script and close.

    3.a. Open the "profile.html" file found in the amember/templates directory.
    3.b. Position your custom fields where you want them to be.

    3.c. Make sure they follow the format below:

    <tr>
    <td>Telephone No: </td>
    <td><input type="text" name="telephone_no"
    value="{$user.telephone_no|escape}" size="30" /></td>
    </tr>


    3.d. When you have complete placing your custom fields, save the "profile.html".

    4.a. Upload "profile.php to the amember directory
    4.b. Upload "profile.html" to the amember/templates directory.

    I hope that this helps other member of this forum.


    Dereck
  2. draj

    draj New Member

    Joined:
    Dec 29, 2006
    Messages:
    252
    Hallo!

    Something like this would be also needed for my work and really big thanks to Alex and yourself for working this little but useful piece of code.

    However, my request is to centralise the code in both the places i.e. admin/user.php and profile.php if possible.
  3. chuck

    chuck aMember Pro Customer

    Joined:
    Aug 29, 2006
    Messages:
    2
    This works well in profile.html/profile.php. However, I am not able to get this to work in the signup form. I get the fields added no problem, but the data is not added to the member's record.

    Any suggestions?
  4. draj

    draj New Member

    Joined:
    Dec 29, 2006
    Messages:
    252
    Hi,
    Did you assign the respective template variables like $t-> that may capture the form input and add them into the array? If not, how will the template array know that there is one more creation mapped?
  5. scottd

    scottd New Member

    Joined:
    Feb 27, 2008
    Messages:
    2
    I am still using the trial version, is this the reason the code in "profile.php" is encoded and therefore I am not seeing the information you are describing?
  6. cabral91

    cabral91 New Member

    Joined:
    Jun 11, 2008
    Messages:
    3
    I have a question regarding this aswell.

    I want to be able to provide a paying subscriber more fields in there profile
    can this same process be used as described above

    if a free member then show
    fields 1 2 3

    if paying

    fields 1 2 3 4 5 6 or even show a totally different set of fields a b c d e

    if i am not clear i can explain better

    thanks
    Jay
  7. cabral91

    cabral91 New Member

    Joined:
    Jun 11, 2008
    Messages:
    3
    Anyone??? Please help
  8. neutron

    neutron New Member

    Joined:
    Jul 29, 2008
    Messages:
    16
    In signup.html we use {if $smarty.request.price_group == 1}
    or {if in_array($smarty.request.price_group, array(3,5,6))} to customize the signup form for price groups

    What's the code difference to do the same thing in profile.html (not $smarty.request.price_group == 1, I've tested it) and take full advantage of your add fields modification?

Share This Page