Skip to content

Am_Lite

Am_Lite is a special class that you may include in your application to get access to aMember database information without overhead of including the entire aMember Pro codebase and its bootstrap. Am_Lite does not require any other files to work.

This class was designed to retrieve data about currently logged in user within 3rd party PHP scripts. Do not use this class within aMember codebase.

From any your PHP file (located outside of aMember), include the Lite.php library:

<?php
require_once '/home/myusername/public_html/amember/library/Am/Lite.php';

If you use aMember with Wordpress and has aMember plugin installed in wordpress already, you can access Am_Lite API from Wordpress php files or templates:

$lite = am4PluginsManager::getAPI();

Am_Lite class is located inside file amember/library/Am/Lite.php and provides the following functions:

$lite = Am_Lite::getInstance();
Check if user logged in and have required subscription otherwise redirect to login page or no-access page. Check $search parameters below
Section titled “Check if user logged in and have required subscription otherwise redirect to login page or no-access page. Check $search parameters below”
Am_Lite::getInstance()->checkAccess($search);
Am_Lite::getInstance()->isLoggedIn();
Am_Lite::getInstance()->getUsername();
Returns first&last name of logged-in customer, not HTML-escaped!
Section titled “Returns first&last name of logged-in customer, not HTML-escaped!”
Am_Lite::getInstance()->getName();
Returns e-mail address of logged-in customer, not HTML-escaped
Section titled “Returns e-mail address of logged-in customer, not HTML-escaped”
Am_Lite::getInstance()->getEmail();
Returns array of all user fields for logged-in customer
Section titled “Returns array of all user fields for logged-in customer”
Am_Lite::getInstance()->getUser();
Am_Lite::getInstance()->getLogoutURL();
Am_Lite::getInstance()->getProfileURL();
Am_Lite::getInstance()->getLoginURL();
Am_Lite::getInstance()->getSignupURL();
Am_Lite::getInstance()->renderLoginForm();
Am_Lite::getInstance()->getRootURL();
Am_Lite::getInstance()->haveSubscriptions($search);
Am_Lite::getInstance()->hadSubscriptions($search);
Am_Lite::getInstance()->getExpire($search);
Return all payment records for currently logged-in user
Section titled “Return all payment records for currently logged-in user”
Am_Lite::getInstance()->getPayments();
Section titled “Return all links defined for currently logged-in user”
Am_Lite::getInstance()->getUserLinks();
Return all access records for currently logged-in user
Section titled “Return all access records for currently logged-in user”
Am_Lite::getInstance()->getAccess();
Has the currently logged-in user an active subscription?
Section titled “Has the currently logged-in user an active subscription?”
Am_Lite::getInstance()->isUserActive();
Get array of all defined in aMember products [product_id => title]
Section titled “Get array of all defined in aMember products [product_id => title]”
Am_Lite::getInstance()->getProducts()
Get array of all defined in aMember product categories [product_category_id => title]
Section titled “Get array of all defined in aMember product categories [product_category_id => title]”
Am_Lite::getInstance()->getCategories()
Retrieve array of product ids that is member of specific category
Section titled “Retrieve array of product ids that is member of specific category”

accept either single category id or array of category ids as argument

Am_Lite::getInstance()->getCategoryProducts($category_id)

There are functions that utilize the $search parameter. It may be:

  • array of product ids, for example [1,3]
  • constant Am_Lite::ANY - subscription to any product
  • constant Am_Lite::PAID - any not-free subscription
  • constant Am_Lite::FREE - any free subscription
  • constant Am_Lite::ONLY_LOGIN - only check that user is logged in