insert member_id into a second table on sign-up

Discussion in 'Customization & add-ons' started by raw8888, May 28, 2012.

  1. raw8888

    raw8888 New Member

    Joined:
    May 29, 2011
    Messages:
    12
    When new member signs up how can the member_id also be inserted into a second (custom) table
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You can use userAfterInsert hook.
    For example in site.php:
    PHP:
            Am_Di::getInstance()->hook->add(Am_Event::USER_AFTER_INSERT'onUserAfterInsert');
            function 
    onUserAfterInsert(Am_Event $event){
                
    $user $event->getUser();
                
    /// Add code that will insert $user->user_id to other table            
            
    }
  3. raw8888

    raw8888 New Member

    Joined:
    May 29, 2011
    Messages:
    12
    Thanks Alexander... but still confused. Not familiar with the code offered. do I add it to the signup.php page? and where do i direct to the proper database and column? Any help would be appreciated.

    Thanks again
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Above should be added to /amember/application/configs/site.php
    You also have to add code that will update your third-party database as well.
  5. raw8888

    raw8888 New Member

    Joined:
    May 29, 2011
    Messages:
    12
    Thanks again.. My amember does not have that path. No application file using Version 3.2.3PRO
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    For amember 3 you can place this code to /amember/site.inc.php:
    PHP:
    setup_plugin_hook('finish_waiting_payment''fwp'); 
    function 
    fwp($payment_id){
    $payment $GLOBALS[db]->get_payment($payment_id);
    // $payment[member_id] - user id;
    // Now place your code that will add user id to third party database. 

    }
  7. raw8888

    raw8888 New Member

    Joined:
    May 29, 2011
    Messages:
    12
    This is how my file looks... not an expert by any stretch. HELP!!! just need to add the new users member_id to the second table .
    <?php

    if (!defined('INCLUDED_AMEMBER_CONFIG'))
    die("Direct access to this location is not allowed");

    /*
    * aMember Pro site customization file
    *
    * Rename this file to site.inc.php and put your site customizations,
    * such as fields additions, custom hooks and so on to this file
    * This file will not be overwritten during upgrade
    *
    */

    setup_plugin_hook('finish_waiting_payment', 'fwp');
    function fwp($payment_id){
    $payment = $GLOBALS[db]->get_payment($payment_id);
    // $payment[member_id] - user id;
    // Now place your code that will add user id to third party database.

    $sql_memberUpdate = 'INSERT INTO recruiter_specialties ('$payment[member_id]', 0)';

    }
    ?>

Share This Page