PHP Include
From AMember Pro Manual
This plugin allow you add cookie-based login for protected-pages. It is particularly useful for adding paid membership support to an existing PHP-based application.
If your existing content is in standard .html files rather than .php files, see New_rewrite
Useful if:
- All your protected content, including images, is stored in PHP files.
Not useful if:
- Images, downloadable content or other non-PHP files are included in your protected content.
[edit] Requirements
- No special requirements
[edit] Setting Up Protection
Note: use aMember CP -> Protect Folders function instead. Described below is a manual procedure, and should be used only if aMember CP -> Protect Foldes doesn't work for you by some reason.
For this plugin to work the file /amember/plugins/protect/php_include/check.inc.php must be included at the very top (before the opening <html> tag) of the PHP pages you wish to protect as follows:
<?php $_product_id = array(1,3); include("aMember_Root_Dir/plugins/protect/php_include/check.inc.php"); .. any existing PHP code goes here .. ?>
Note: You must edit the $_product_id array to reflect the aMember product which gives access to the page. For example, if access is confined to those with products 1 and 3 it will be as above. If it is confined to those with products 2 and 5 you would use $_product_id = array(2,5);
Note: aMember_Root_Dir must be replaced with actual unix path (not URL!) to aMember folder. You can find this path at aMember CP, on the "Welcome to aMember Pro Control Panel" screen, in the "Software version info" table. It is named Root Folder.
[edit] How does it work (for programmers only)
When a user enters a URL to the protected page the aMember login form is displayed and the user enters a username/password. This information is compared to entries in the member database to determine whether a user has the right credentials
- If the user has an active subscription to the product or products as defined in $_product_id then the protected page will be displayed.
- If the user is not authorized yet, or has an expired subscription, then the login form is displayed again with an error message.
If you are not using subscriptions or wish to allow any member to have access to a page, regardless of the subscriptions they hold, then you can define $_product_id as $_product_id = array('ONLY_LOGIN'); This simply checks that the username and password exist in the database. Be careful - it will allow access for non paying or expired members!
