Difference between revisions of "API/Lite"

From aMember Pro Documentation
Jump to: navigation, search
(Created page with "Am_Lite is a special class that you may include into your application to get access to aMember database information without overhead of including entire aMember Pro codebase and ...")
 
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Am_Lite is a special class that you may include into your application to get access to aMember database information without overhead of including entire aMember Pro codebase and its bootstrap. Am_Lite does not require any other files to work.
+
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.
 +
 
 +
From any your PHP file (located outside of aMember), include the Lite.php library:
 +
<source lang="php">
 +
<?php
 +
require_once '/home/myusername/public_html/amember/library/Am/Lite.php';
 +
</source>
  
 
Am_Lite class is located inside file ''amember/library/Am/Lite.php'' and provides the following functions:
 
Am_Lite class is located inside file ''amember/library/Am/Lite.php'' and provides the following functions:
 +
; ''Am_Lite::getInstance()->checkAccess($search)''  : check if user logged in and have required subscription otherwise redirect to login page or no-access page
 +
; ''Am_Lite::getInstance()->isLoggedIn()''  : checks if user has been authenticated
 +
; ''Am_Lite::getInstance()->getUsername()''  : get username
 +
; ''Am_Lite::getInstance()->getName()''  : returns first&last name of logged-in customer, not HTML-escaped!
 +
; ''Am_Lite::getInstance()->getEmail()''  : returns e-mail address of logged-in customer, not HTML-escaped
 +
; ''Am_Lite::getInstance()->getUser()''  : returns array of all user fields for logged-in customer
 +
; ''Am_Lite::getInstance()->getLogoutURL()''  : returns URL of aMember logout page
 +
; ''Am_Lite::getInstance()->getProfileURL()''  : returns URL of aMember user profile page
 +
; ''Am_Lite::getInstance()->getLoginURL()''  : returns URL of aMember login page
 +
; ''Am_Lite::getInstance()->getSignupURL()''  : returns URL of aMember signup page
 +
; ''Am_Lite::getInstance()->renderLoginForm()'' : renders aMember login form
 +
; ''Am_Lite::getInstance()->getRootURL()''  : returns root URL of aMember installation
 +
; ''Am_Lite::getInstance()->haveSubscriptions($search)''  : returns true if user have active subscription to ''$search''
 +
; ''Am_Lite::getInstance()->hadSubscriptions($search)''  : return true if user had before or has now subscription to ''$search''
 +
; ''Am_Lite::getInstance()->getExpire($search)''  :  return greatest expiration date for ''$search''
 +
; ''Am_Lite::getInstance()->getPayments()''  :  return all payment records for currently logged-in user
 +
; ''Am_Lite::getInstance()->getUserLinks()''  : return all links defined for currently logged-in user
 +
; ''Am_Lite::getInstance()->getAccess()''  :  return all ''access'' records for currently logged-in user
 +
; ''Am_Lite::getInstance()->isUserActive()''  : has the currently logged-in user an active subscription?
 +
; ''Am_Lite::getInstance()->getProducts()''  : get array of all defined in aMember products (product_id => title)
  
; '''Am_Lite::getInstance()''' : asdasd
+
There are functions that utilize the ''$search'' parameter. It may be:
 +
* array of product ids, for example ''array(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

Latest revision as of 07:09, 18 March 2016

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.

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';

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

Am_Lite::getInstance()->checkAccess($search)  
check if user logged in and have required subscription otherwise redirect to login page or no-access page
Am_Lite::getInstance()->isLoggedIn()  
checks if user has been authenticated
Am_Lite::getInstance()->getUsername()  
get username
Am_Lite::getInstance()->getName()  
returns first&last name of logged-in customer, not HTML-escaped!
Am_Lite::getInstance()->getEmail()  
returns e-mail address of logged-in customer, not HTML-escaped
Am_Lite::getInstance()->getUser()  
returns array of all user fields for logged-in customer
Am_Lite::getInstance()->getLogoutURL()  
returns URL of aMember logout page
Am_Lite::getInstance()->getProfileURL()  
returns URL of aMember user profile page
Am_Lite::getInstance()->getLoginURL()  
returns URL of aMember login page
Am_Lite::getInstance()->getSignupURL()  
returns URL of aMember signup page
Am_Lite::getInstance()->renderLoginForm() 
renders aMember login form
Am_Lite::getInstance()->getRootURL()  
returns root URL of aMember installation
Am_Lite::getInstance()->haveSubscriptions($search)  
returns true if user have active subscription to $search
Am_Lite::getInstance()->hadSubscriptions($search)  
return true if user had before or has now subscription to $search
Am_Lite::getInstance()->getExpire($search)  
return greatest expiration date for $search
Am_Lite::getInstance()->getPayments()  
return all payment records for currently logged-in user
Am_Lite::getInstance()->getUserLinks()  
return all links defined for currently logged-in user
Am_Lite::getInstance()->getAccess()  
return all access records for currently logged-in user
Am_Lite::getInstance()->isUserActive()  
has the currently logged-in user an active subscription?
Am_Lite::getInstance()->getProducts()  
get array of all defined in aMember products (product_id => title)

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

  • array of product ids, for example array(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