aMember is a member management, ecommerce program. One use is for recurring billing for subscriptions.
When you purchase aMember you can buy the EE plug in. This allows you to integrate aMember with EE, and when a person purchases a subscription you can assign them a member group id. The purpose of this is you can protect certain weblogs and templates where only people with that group id can view the content.
The way aMember works is that when a person signs up for an aMember account they are also added to the EE database, via the aMember EE plug in.
When they purchase a subscription their member group is updated to the group associated with the subscription.
Here is where it gets interesting. On your web site when they login to aMember it also logs them into EE. If you login to EE it does NOT log you into aMember.
I am using EE for the main page of my web site, and in the left column I wanted to have a box with the member info, if they are logged in give them a link to their aMember account info page. If they are not logged in I show the box for the username, password and a login button. I also wanted to use the “remember me” feature so when they return to the web site they will be logged in, which makes it much easier for customers to go directly to the “members” (protected) section of the web site.
The problem I ran into is that because the main page is EE, it was not activating aMember to find out if a person was logged on or not, so every time they came to the web site they had to log in. Once logged in they could navigate the site as long as they did not close the browser.
Here are the steps I took to fix the problem.
In the aMember CP (control panel)
setup/config - Plugins.
For the “Protect Plugins you have to select ee & php_include
setup/confi - PHP Include
Remember Login has to be set to Yes
--- if you want to use the “remember me box” set Always remember to No
--- Remember Period you can set to any length you want. Just ask yourself how often do you want to force the customers to log in.
The next step is to use a text editor and insert this line into the index.php file
// the next line is to call the aMember system to load the login
include “path_to/amember/plugins/protect/php_include/reload_if_cookie.inc.php”;
Now for the last step.
In the EE CP > Templates > edit template (i.e. the index template if this is for your main page.)
In my template I have a sidebar on the left where I wanted the “members” info at. so here is the template code used.
----------------------------------------------------------------------------------------
<div id="sidebar">
<h3>Members</h3>
<ul>
{if logged_in}
<li>Welcome {screen_name}</li>
<li><a href='/amember/member.php'>Your Account</a></li>
<li><a href='/amember/logout.php'>Logout</a></li>
{/if}
{if logged_out}
<form method=post action='/amember/login.php'>
Username: <input type=text name=amember_login size=10><br>
Password : <input type=password name=amember_pass size=10><br>
<input type="checkbox" name="remember_login" value="1">
<span class="small">Remember me</span>
<input type=submit value='Login'>
</form>
<li><a href='/amember/login.php'>Forgot Password</a></li>
<li><a href='/amember/signup.php'>Register</a></li>
{/if}
</ul>
-------------------------------------------------------------------------------------------------
NOTE: I am currently using the EE “logged in” tag, and the welcome line uses the EE username/screen name tag.
Basically it was late at night when I finally got the remember me part to work, and I didn’t have time to change that code to use the amember variables of the user session, or the user first and last names for the welcome line.
The href lines are based from the root directory.
Basically this did the trick, I can use EE for my main page, and when the user returns to my web site they are remembered and logged in if they checked the “remember me” box.
Jim.
UPDATE 9/13/2007
I was scanning the aMember forums when I stumbled on a thread that pertains to this issue. www.amember.com/forum/showthread.php?t=2819&page=2
I have NOT had a chance to test this code yet, but I wanted to share it as it appears this would use the aMember logged in flag instead of the EE logged in flag, which would have an advantage due to how these 2 programs are integrated.
The following code should point you in the right direction, and once tested this wiki can be updated.
<?php session_start(); if ($_SESSION['_amember_id']) { ?>
<p align="CENTER">
<b><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">
MY ACCOUNT
</p></font>
<p align="left">
<b><font color="grey" size="1" face="Verdana">
<a href="http://www.website.com/amember/member.php">My Memberships</a><br />
<a href="http://www.website.com/amember/profile.php">My Profile</a><br />
<a href="http://www.website.com/amember/logout.php">Logout</a><br />
</b></font>
</p>
<?php } else { ?>
<form action="http://www.website.com/amember/login.php" method=post>
Username: <input type=text name=amember_login size=10><br />
Password: <input type=password name=amember_pass size=10><br />
<input type=checkbox name=remember_login value=1>Remember me
<input type=submit value=Login>
</form>
<?php } ?>
