Getting user name

I'm doing some custom stuff for a client where logged in users are able to select certain things then submit. Their selection then goes to the DB and an email is sent to client.

I've got everything except I can't figure out how to grab their username. Right now I'm hard coding it for testing - Doesn't even have to be username - ID or email address would work too.

Please help,
Thanks,
Mike

Comments

  • acrylian Administrator, Developer
    THe object of the current logged in user is availabe in the global variable `$_zp_current_admin_obj`. The object is from the `Zenphoto_Administrator` class:
    http://www.zenphoto.org/documentation/classes/_lib-auth.php.html

    To get a specific user use `$userobj = Zenphoto_Authority::newAdministrator("', 1);`
  • fretzl Administrator, Developer
    I think you're looking for something like this:

    `
    <?php
    if ( zp_loggedin() ) {
    $username = $_zp_current_admin_obj->getUser();
    }
    ?>
    `
    This gets the User name of the current logged-in user.
  • acrylian Administrator, Developer
    Right ;-) The naming of methods is a bit confusing as there is also a method `getName()` which actually refers to the optional "full name" and not the "user name".
  • Cool I got it. Thanks guys. Now I'm having an issue with Safari only where the user gets logged out when I "add" something to a cart. (but they are really still logged in) It appears as if hitting the add button adds the www to the url bar and safari doesn't like this. If I manually remove the www I'm back to being logged in.

    On the other hand IE works perfectly as-is...but if I manually remove the WWW it shows as if I'm logged out...but again really logged in...No issues there because it works fine as-is. But for some reason Safari is being weird...Mozilla works fine either way

    Is this a DNS, WWW vs no WWW issue?

    Any ideas are welcome...Everything else is perfect except this little issue. As it turns out both partners use MAC's so I kind of have to get this straightened out! lol

    Thanks,
    Mike
  • acrylian Administrator, Developer
    Since the cart you are using is not Zenphoto I would look for the issue there. Maybe a config issue of the cart?
  • It's completely custom. Turned out to be a relative path issue that only Safari didn't like. It's all straightened out now.

    Thanks again
Sign In or Register to comment.