Copy Custom Address Fields to aMember Address Fields

Discussion in 'Troubleshooting' started by vacc_webmaster, Nov 15, 2010.

  1. vacc_webmaster

    vacc_webmaster Member

    Joined:
    Jan 24, 2007
    Messages:
    51
    I have three custom fields that are used to store members address, city, state, and zip.

    I would like to transfer data from those custom fields into amember address fields, so then they can be used to pass the address to PayPal.

    How can this be accomplished because within the database it stores it in one field called "data"

    Thanks for any advice (either 1) transfer address info from field to field or b) allow my custom address fields to be passed to PayPal.
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You can do this using this php script:
    PHP:
    <?
    include 
    "/path/to/amember/config.inc.php";
    $q $db->query("select member_id,data from amember_members");
    while(list(
    $id$data) = mysql_fetch_row($q)){
    $u $db->get_user($id);
    $data unserialize($data);
    $u['street'] = $data['YOURSTREETFIELDNAME'];
    $u['country'] = $data['YOURCOUNTRYFIELDNAME'];
    $u['zip'] = $data['YOURZIPFIELDNAME'];
    $u['city'] = $data['YOURCITYFIELDNAME'];
    $u['state'] = $data['YOURSTATEFIELDNAME'];
    $db->update_user($id$u);


    ?>
    Please backup database first.
  3. vacc_webmaster

    vacc_webmaster Member

    Joined:
    Jan 24, 2007
    Messages:
    51
  4. vacc_webmaster

    vacc_webmaster Member

    Joined:
    Jan 24, 2007
    Messages:
    51
    OK, I was able to execute it. Everything went fine except it didn't carry over the state and country.

    How can I set all member's state and country to be the same in the database for the two built in amember address fields?

    It should be VA for state and US for country for all current members.

    Thank you!
  5. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Code:
    update amember_members set country = 'US', state='VA'
    
    

Share This Page