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:
Get Library instance;
$lite = Am_Lite::getInstance();
$search parameters below
Check if user logged in and have required subscription otherwise redirect to login page or no-access page. CheckAm_Lite::getInstance()->checkAccess($search);
Checks if user has been authenticated
Am_Lite::getInstance()->isLoggedIn();
Get Username
Am_Lite::getInstance()->getUsername();
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
Am_Lite::getInstance()->getEmail();
Returns array of all user fields for logged-in customer
Am_Lite::getInstance()->getUser();
Returns URL of aMember logout page
Am_Lite::getInstance()->getLogoutURL();
Returns URL of aMember user profile page
Am_Lite::getInstance()->getProfileURL();
Returns URL of aMember login page
Am_Lite::getInstance()->getLoginURL();
Returns URL of aMember signup page
Am_Lite::getInstance()->getSignupURL();
Renders aMember login form
Am_Lite::getInstance()->renderLoginForm();
Returns root URL of aMember installation
Am_Lite::getInstance()->getRootURL();
$search
Returns true if user have active subscription toAm_Lite::getInstance()->haveSubscriptions($search);
$search
Return true if user had before or has now subscription toAm_Lite::getInstance()->hadSubscriptions($search);
$search
Return greatest expiration date forAm_Lite::getInstance()->getExpire($search);
Return all payment records for currently logged-in user
Am_Lite::getInstance()->getPayments();
Return all links defined for currently logged-in user
Am_Lite::getInstance()->getUserLinks();
Return all access records for currently logged-in user
Am_Lite::getInstance()->getAccess();
Has the currently logged-in user an active subscription?
Am_Lite::getInstance()->isUserActive();
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]
Am_Lite::getInstance()->getCategories()
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)
Search Parameter
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