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.

Click to hide
Contents (hide)

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.

<?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.

<?php
echo $user[field_name_here];
?>
<?php
echo $user[fiRSt_NaMe];
?>

Special Information That Can Also Be Displayed

<?php
echo $user_areas;
?>
<?php
echo $days_remaining;
?>
<?php
echo $current_date;
?>
Field Name Display Code What it Displays
username $user[username] User’s username.
email $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.

[1] Note that you server’s full server path will be different from the one listed below. You can find the correct path by clicking “Setup” within the admin control panel and then copying and pasting the absolute path available within the option entitled “Program FSP”
[2] The list will be formatted using bullet points
[3] The date will be formatted based on the “Date Format” option within the program’s “Setup”

This page last modifed by admin @ 04 August 2009 05:58. Created on 23 May 2009 08:33 Protected Page