modifying additional field value upon upgrade and sign up

Discussion in 'Customization & add-ons' started by laguitar, Apr 26, 2011.

  1. laguitar

    laguitar aMember Pro Customer

    Joined:
    Jun 16, 2009
    Messages:
    12
    Hi,

    I need to update a user's additional custom field when he signs up using the signup.php AND when he/she upgrades using member.php?tab=add_renew.

    I guess it would involve sth like this:

    Code:
    $user['data']['my_field'] = 'new_value_upon_signup'; 
    but I'm not sure where to insert it. Does this go on the template files using smarty, or on the signup.php and member.php? And where should it be placed?

    Thanks in advance!

    p.s. I should add that this is a common field. Then it doesn't need to be added to the database, is that correct?
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    On the signup form, it should appear automatically in the additional fields settings- if you have it set to be editable and displayed in the signup.

    Can you explain the usage of this?

    David
  3. laguitar

    laguitar aMember Pro Customer

    Joined:
    Jun 16, 2009
    Messages:
    12
    I just meant when a user upgrades from within the account.

    The field is meant to be like a tracker so it is set to 'don't display'.
    Thanks.
  4. laguitar

    laguitar aMember Pro Customer

    Joined:
    Jun 16, 2009
    Messages:
    12
    Still looking for a solution to this... I also opened a support ticket and they are being very helpful, but no solution so far unfortunately. So I wanted to get some thoughts from the community, as well.

    They suggested using a hook like this:


    So, the idea is to update the additional field, 'field_name', each time a payment (hence the '$payment['amount']>0') is completed.

    This would be perfect, however the field is not being updated when I add a subscription to a user on the admin panel. Are we missing anything here?

    This code is set in site.inc.php as suggested. I should also add that an additional 'common' field is created with the name 'field_name'.

    I'd appreciate any thoughts.
  5. laguitar

    laguitar aMember Pro Customer

    Joined:
    Jun 16, 2009
    Messages:
    12
    Also wanted to add that with the above code, I get the error:

    <b>WARNING:</b> Cannot modify header information - headers already sent by (output started at /home/toganet/public_html/members/site.inc.php:46) in line 238 of file /home/toganet/public_html/members/includes/pear/Services/JSON.php

    <b>WARNING:</b> Cannot modify header information - headers already sent by (output started at /home/toganet/public_html/members/site.inc.php:46) in line 353 of file /home/toganet/public_html/members/admin/ajax_cnt.php

    Any ideas, anyone?
  6. laguitar

    laguitar aMember Pro Customer

    Joined:
    Jun 16, 2009
    Messages:
    12
    I got rid of the above errors by removing the extra spaces at the bottom of site.inc.php.

    However, the field is still not updated.
  7. laguitar

    laguitar aMember Pro Customer

    Joined:
    Jun 16, 2009
    Messages:
    12
    In addition, I added these lines

    and

    on plugins/protect/plugin_template/plugin_template.inc.php in proper places, and enabled the plugin 'plugin_template' in the cp panel.

    This is when I got the error:

    Error. Please configure 'plugin_template' plugin at aMember CP -> Setup -> plugin_template

    However, on the config settings, we have these fields:

    It is a simple config field
    this field will be available as $this_config['cfg_field'] in the plugin code
    plugin_template Db and Tablename
    AN EXAMPLE OF COMPLEX FIELD WITH VALIDATION

    And I'm not sure what goes in these fields, and this is not documented in the manual or else where.

    Any thoughts, anybody? Alex?
    Thanks again for your time.
  8. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    I'm not sure why you need plugin_template enabled. In regards to code in site.inc.php can you copy & paste code that you have in that file currently.
    Also, screenshot of additiona filed that should be updated settings
  9. rendersnag

    rendersnag Member

    Joined:
    Jan 28, 2011
    Messages:
    35
    Hi laguitar, any resolution on this? I am having the same issue. I cannot get the additional field to update. Using almost the same exact code for the hook.
  10. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    What type of field you have ? There is a difference between common and sql fields.
    For common you should use:
    $member['data']['field_name'] = 'field_value';
    for SQL:
    $member['field_name'] = 'field_value';

Share This Page