renewal, update new fields

Discussion in 'Customization & add-ons' started by khoa, Aug 3, 2011.

  1. khoa

    khoa New Member

    Joined:
    Aug 3, 2011
    Messages:
    1
    I have a couple of extra required fields on my renewal page here (http://www.ilispa.org/amember/member.php?tab=add_renew) Use test/tester for login. These fields aren't being updated when the user renews.


    Im following this example here ( http://manual.amember.com/Using_site.inc.php_and_hooks#finish_waiting_payment.28.24payment_id.29 ) and putting it in my site.inc.php

    i cant seem to print_r($payment) as nothing shows up, so I'm not sure if the function is even being called. Are those extra fields stored in $payment anyways?

    function fwp($payment_id){

    global $db;
    $payment = $db->get_payment($payment_id); // $payment is now an array
    $product = $db->get_product($payment['product_id']);
    $member = $db->get_user($payment['member_id']);

    $user_array['data']['print_card'] = $payment['print_card'];
    $user_array['data']['print_newsletter'] = $payment['print_newsletter'];
    // Update DB with required fields
    $db->update_user( $payment['member_id'], $user_array );

    }


    // Also the example doesn't explicitly state to use setup_plugin_hook(), is that needed? I have included it anyways but doesn't seem to make a difference.

    setup_plugin_hook('finish_waiting_payment', 'fwp');
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Couple of issues:
    1. You should use add_payment_field function in order to add these fields to payment profile.
    add_payment_field('print_card', 'Print card', 'text');
    add_payment_field('print_newsletter', 'Print newsletter', 'text');

    2. This block is not correct:
    $user_array['data']['print_card'] = $payment['print_card'];
    $user_array['data']['print_newsletter'] = $payment['print_newsletter'];
    $db->update_user( $payment['member_id'], $user_array );

    should be

    $member['data']['print_card'] = $payment[data]['print_card'];
    $member['data']['print_newsletter'] = $payment[data]['print_newsletter'];
    $db->update_user( $payment['member_id'], $member );

    3. make sure that fields are added in amember CP -> Add fields and field type set to common.

Share This Page