api lite user_id

Discussion in 'Templates customization' started by raw8888, Jul 9, 2012.

  1. raw8888

    raw8888 New Member

    Joined:
    May 29, 2011
    Messages:
    12
    trying to pull out the user_id. It appears in the array. but how can I use it. not listed in the wiki page.

    <?php
    include '../amember/library/Am/Lite.php';
    print_r(Am_Lite::getInstance()->getUser());
    $member_id =WHAT DO I PUT HERE;
    print_r ($member_id);
    ?>

    thanks
  2. trafficbrowser

    trafficbrowser aMember Pro Customer

    Joined:
    Oct 30, 2011
    Messages:
    46
    What I did was build a function do this.

    I hope this gives you some kind of idea.

    PHP:
        // @returns the aMember user if from the user name.
        
    public function get_aMember_user_id_from_username($username) {
     
            
    $sql "SELECT user_id FROM amtb_user WHERE login = ? LIMIT 1";
            
    $q $this->db->query($sql$username);
     
            if (
    $q->num_rows() >0)
            {
                return 
    $q->row()->user_id;
            }
        }
     
    You might need to handle your own database connection because I am using CodeIgniter but hopefully you will get the idea. "amtb_user" might be different check your amember mysql install
  3. duncan_m1

    duncan_m1 Challenge Media Group LLC

    Joined:
    Aug 22, 2006
    Messages:
    12
    PHP:
    include '../amember/library/Am/Lite.php';
    $user Am_Lite::getInstance()->getUser();
    $member_id =$user['user_id'];
    print_r ($member_id);
    this should work for you

Share This Page