Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Charlottesville, VA
    Posts
    51
    Plugin Contributions
    0

    Default Adding the user's name to a sidebox

    I'm customizing a sideblock for a site I am working on. When a user is logged in, I want to show their username in a short greeting message. I thought I had it working with $username, but that doesn't seem to work anymore.

    I've tried quite a bit of checking and searching but "user" is too short a word to search for, so that's made searching difficult.

    Any help?

    Thanks!
    Frank

  2. #2
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Adding the user's name to a sidebox

    It depends whether you want the username, or the user's name....

    If you just want the user's name, as in the firstname of the customer, then you can use this code:

    Code:
    if (isset($_SESSION['customer_id'])) { // check the customer is actually logged in
      echo $_SESSION['customer_first_name'] .' ' . $_SESSION['customer_last_name']; // show the name variables you want to use
    }
    If you want the username (customers_nickname), then you would need to use the customer_id and query the database to get the customer field.

    Absolute
    Back, after a 4 year absence! Did you miss me?
    Absolute Web Solutions Ltd
    Interested in our work? Take a look at one of our sites - The Tech Store

  3. #3
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Adding the user's name to a sidebox

    Just been pointed out that customer_last_name may not be available to you to use.

    I would just like to add that this is in fact set within includes/modules/pages/login/header_php.php on line 88:

    Code:
    $_SESSION['customer_last_name'] = $check_customer->fields['customers_lastname'];
    So my suggestion would be either "try" the code I listed above, or use a database query to return the fields you require from the database, using the $_SESSION['customer_id'] as the key.

    Absolute
    Back, after a 4 year absence! Did you miss me?
    Absolute Web Solutions Ltd
    Interested in our work? Take a look at one of our sites - The Tech Store

  4. #4
    Join Date
    Jan 2009
    Location
    Charlottesville, VA
    Posts
    51
    Plugin Contributions
    0

    Default Re: Adding the user's name to a sidebox

    Your first suggestion worked perfectly. I double checked in the includes/modules/pages/login/header_php.php file and it has the query for both first and last names, and I have no plans to change it.

    Thanks! This is exactly what I needed.

    Frank

 

 

Similar Threads

  1. Change the name of Information Sidebox
    By BigAl49 in forum Basic Configuration
    Replies: 5
    Last Post: 8 Apr 2010, 05:41 PM
  2. Adding User Source to the printed order
    By jdaven123 in forum General Questions
    Replies: 3
    Last Post: 12 Aug 2009, 04:48 PM
  3. Adding fields to the user registration form
    By res in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 8 Aug 2008, 01:53 PM
  4. Change the Sidebox name
    By barbosay in forum Customization from the Admin
    Replies: 1
    Last Post: 24 Sep 2006, 04:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg