In the protected files, I have some php files. I want to show customer's name(of course the user currently seeing that page) and mail-address on the page Any way to retrieve these info from aMember? Thanks in advance!
This one has been answered loads of times. Details of how to here http://www.amember.com/docs/API/Lite
I see that this has been answered loads of time but I am still having problems with it. Am_Lite::getInstance()->getUser() In using this what code do I use to retrieve the first and last name and their member or user ID to follow what they enter on my php pages. This is quit different from the V3 I am use to where you could use: <?php session_start(); print "Welcome " . $_SESSION['_amember_user']['name_f'] . " " . $_SESSION['_amember_user']['name_l']; ?></strong></font> <br> <?php $expire = "---"; // not defined foreach ($_SESSION['_amember_subscriptions'] as $p){ if ($p['completed']) { $expire = $p['expire_date']; } } print "<br>Your Membership Expires on: <br> " . date('m/d/Y', strtotime($expire)); $pr_list = $_SESSION['_amember_products']; $pr = $pr_list[count($pr_list)-1]['title']; print "<br>Type Membership <br> " . $pr; ?> Any help is greatly appreciated.. I only need to get the first last and user or member ID
Anyway I want to answer you here: PHP: <?php $user = Am_Lite::getInstance()->getUser(); echo $user['name_f'];echo $user['name_l'];echo $user['user_id']; $expire = Am_Lite::getInstance()->getExpire(Am_Lite::ANY); echo $expire;
Great to have found this post. So to insert aMember variables into a custom field of a form, is the following method correct: Code: <?php require_once '/home/mysitepath/amember/library/Am/Lite.php'; $user = Am_Lite::getInstance()->getUser(); ?> <form method="post" class="form-horizontal KT_tngformerror" id="form1" role="form" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>"> <input type="hidden" name="kt_login_email" id="kt_login_email" value="<?php echo $user['email']?>" /> <input type="hidden" name="kt_login_login" id="kt_login_login" value="<?php echo $user['login']?>" /> <button type="submit" name="kt_login1" id="kt_login1" value="Insert record" >Get Access Now</button> </form> Although it seems to work, please let me know if there is anything I have done which is incorrect, or that might cause issues with aMember.
@dale_sellers you need to escape data before output it to html eg. htmlentities($user['email']) instead of just $user['email']
It is necessary by security reason to avoid XSS attack (http://en.wikipedia.org/wiki/Cross-site_scripting).
Yes, Caesar is correct - never output user input to a page without filtering it (e.g. via htmlentities) otherwise you can leave yourself open to abuse. e.g. unfiltered, the following value for $user['login'] would trigger an alert on mouseover... Code: a@a.com" onmouseover="alert('Bwah ha ha ha!')
<?php require_once '/home/mysitepath/amember/library/Am/Lite.php'; $user = Am_Lite::getInstance()->getUser(); ?> <form method="post" class="form-horizontal KT_tngformerror" id="form1" role="form" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>"> <input type="hidden" name="kt_login_email" id="kt_login_email" value="<?php echo $user['email']?>" /> <input type="hidden" name="kt_login_login" id="kt_login_login" value="<?php echo $user['login']?>" /> <button type="submit" name="kt_login1" id="kt_login1" value="Insert record" >Get Access Now</button> </form> this code working file sir but How to I update data like name email and pass from custon form how do i do
I am afraid Am_Lite API is read only. It is not possible to use it to update user. Customer need to use profile form in aMember to update his account.