You are viewing version #13 of a page entitled Display Account Info. The page Owner is admin and the last changes were made by admin 13 months ago. There are 540 words in this revision and it has been viewed 607 times.
This page is Protected from any changes.
Displaying Account Information
Overview
Once a user is logged into his/her account, you can display any account information using a simple “include” command and some basic PHP code.
Before using the file, ensure that line 4 on the member_cp/user_data.php file is properly displaying the absolute path to the /ppSD2/admin/mysql.php file. The line looks like this within the program ZIP file:
$FSP = "%%path%%";
Once updated it should look as follows[1]:
$FSP = "/full/server/path/to/ppSD2";
Include the user_data.php File
Important: this code will only work if your file has the .php extension.
- At the top of your PHP file, copy and paste the following code AFTER changing “/full/server/path/to/ppSD2” to reflect the correct full server path to the ppSD2 directory on your server (see previous step):
<?php include "/full/server/path/to/ppSD2/member_cp/user_data.php"; ?>
Determining if a User is Logged In
You can use the following code to determine whether a user is currently logged into his/her account:
<?php
if ($logged_in == "1") {
// The user is logged into his/her ppSD2 account
} else {
// The user is not currently logged in
}
?>
This code is useful because it will allow you to either display login/register or logout//update account links. Example:
<?php
if ($logged_in == "1") {
echo <<<qq
Welcome $user[username] (<a href="/ppSD2/member_cp/edit_account.php">Update Account</a> / <a href="/ppSD2/logout.php">Logout</a>)
qq;
} else {
echo <<<qq
Welcome Guest (<a href="/ppSD2/login.php">Login</a> / <a href="/ppSD2/register.php">Register</a>)
qq;
}
?>
Important: When editing the above code, only change the the text found between the echo <<<qq and qq; lines.
Displaying Specific Account Information
Note: This will only work if the user is logged into his/her account!
Place the any of the following code snippets exactly where you wish for them to appear on your PHP page.
- Display any field within the database using the following format (to view a list of field names, from the admin control panel hover your mouse over “Setup” and click on “List Custom Fields”):
<?php echo $user[field_name_here]; ?>
- The field_name_here is cAsE SeNsITive and based on the list of fields available from “Setup” > “List Custom Fields”
- So if you have a field within the database named “fiRSt_NaMe”, you would include it as follows:
<?php echo $user[fiRSt_NaMe]; ?>
Special Information That Can Also Be Displayed
- Display a list of the user’s secure areas as follows[2]:
<?php echo $user_areas; ?>
- Display how many days a user has left before his/her account expires:
<?php echo $days_remaining; ?>
- Display the date:[3]
<?php echo $current_date; ?>
- Additional fields that can be displayed:
| Field Name | Display Code | What it Displays |
|---|---|---|
| username | $user[username] | User’s username. |
| $user[email] | User’s email. | |
| joined | $user[joined] | Date on which the user joined, formatted according to the “Date Format” option. |
| expires | $user[expires] | Date on which the user’s account expires, formatted according to the “Date Format” option. Displays “Lifetime” if the account does not expire. |
| last_login | $user[last_login] | Date of the user’s last login. |
This page last modifed by admin @ 04 August 2009 05:58. Created on 23 May 2009 08:33 



|