How to query list of users for particular product

Discussion in 'Customization & add-ons' started by lifeworks, Oct 11, 2012.

  1. lifeworks

    lifeworks New Member

    Joined:
    Mar 15, 2012
    Messages:
    4
    Hey guys. Been searching the forums and knowledgebase and can't find any help on this one. I need to generate a list of users (both active or pending) for a particular product. If there was a option to include the product in the 'Browse Users' grid that would be perfect, but doesn't exist. My products are for retreats in which a user can pay immediately or wait and pay cash at the retreat. Currently in AM I'm only able to get lists of the members who have already paid, which doesn't include the ones who will pay later. I need to get an attendance list for each retreat (product), despite payment. I can't find a table in the database that pairs up the product_id with the user_id. Can anyone shed some light on this? Thanks!
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Hi,
    the table that connects users with products is named "am_access". If you query it without taking periods into account it will work
    select u.* from am_user u inner join am_access a using (user_id) where a.product_id=123;

    You may also use "Advanced" user search conditions. Click "Advanced Search" on "Browse Users" screen, and choose condition "Subscribed to any of (including expired)" - it will select all users who have (or had) subscription to selected products.
  3. lifeworks

    lifeworks New Member

    Joined:
    Mar 15, 2012
    Messages:
    4
    Hey Alex,

    Thanks for the reply. That would work perfect except it doesn't include pending users. When I go to Browse Users I've got 33 listed, but only the 15 active users are showing up in the filters. And there are only 15 records in the am_access table. The trick is to include the pending users as well. Seems like if the entire user list is viewable under Browser Users then the should be a way to filter them based on a product they purchased.

    Or is the only to achieve that by making all users Active, even if they haven't paid yet?
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Unfortunately, filters are executed as AND, so each condition must match.
    In your case you need to make 2 searches - one for active users and second for pending.

Share This Page