I need to be able to collect and then display member data. Previously I used session variables. Since v.4 and AM_Lite I cannot get this to work. This is the previous code that would allow users to see only their data. Can anyone help with this? Code: if (isset($_SESSION['_amember_id'])) { $colname_rsGoals = $_SESSION['_amember_id']; } mysql_select_db($database_connExercise, $connExercise); $query_rsGoals = sprintf("SELECT * FROM goals WHERE `_amember_id` = %s ORDER BY data_id DESC", GetSQLValueString($colname_rsGoals, "text")); $rsGoals = mysql_query($query_rsGoals, $connExercise) or die(mysql_error()); $row_rsGoals = mysql_fetch_assoc($rsGoals); $totalRows_rsGoals = mysql_num_rows($rsGoals);
Here is example which should work: PHP: $lite = Am_Lite::getInstance();if($lite->isLoggedIn()){ $user = $lite->getUser(); $colname_rsGoals = $user['user_id'];}mysql_select_db($database_connExercise, $connExercise);$query_rsGoals = sprintf("SELECT * FROM goals WHERE `_amember_id` = %s ORDER BY data_id DESC", GetSQLValueString($colname_rsGoals, "text"));$rsGoals = mysql_query($query_rsGoals, $connExercise) or die(mysql_error());$row_rsGoals = mysql_fetch_assoc($rsGoals);$totalRows_rsGoals = mysql_num_rows($rsGoals);
That works great, thanks! One other issue: I need to pull the user_id from the amember_user table. In the wiki, I don't see user_id. For instance I understand that the following will pull the username. Am_Lite::getInstance()->getUsername() I need the user_id. Is this possible. Do I have to modify the Lite.php file? Thank you.
this will return you user_id: PHP: $lite = Am_Lite::getInstance();if ($lite->isLoggedIn()){ $user = $lite->getUser(); $user_id = $user['user_id']; /// there is the id you are looking for}
Alex - It's not working for me. What I need this for is to allow users to update their information. It's in a form as a hidden field and needs to be dropped into the data base in order to allow retrieval after being updated. Here's the exact code for the hidden field: Code: <input name="_amember_id" type="hidden" id="_amember_id" value="<?php $lite = Am_Lite::getInstance(); if ($lite->isLoggedIn()) { $user = $lite->getUser(); $user_id = $user['user_id']; } ?>" /> I must be missing something? My database updates but in the _amember_id field is shows "Array" instead of the user_id.
Here is correct code: PHP: <?php $lite = Am_Lite::getInstance();if ($lite->isLoggedIn()){ $user = $lite->getUser(); $user_id = $user['user_id'];} ?><input name="_amember_id" type="hidden" id="_amember_id" value="<?php echo $user_id; ?>" />