Pulling user cookie in image template

I'm setting up a "Favorites" function where people can save images as their "favorite". To do this, I need to pull a user variable (either username or id) in the image template. (This would obviously only pull if someone was logged in.) Is there a way to do this? Thanks! I tried various different variables from elsewhere in the script, but none of them seemed to work.

Comments

  • You should use the global variable `$_zp_current_admin_obj`, which is an instance of the currently logged in admin object. From that, you can use the class methods of this object (`Zenphoto_Administrator` found in `lib-auth.php`) to grab whatever information you need.

    I should also mention that if the current user is not logged in, `$_zp_current_admin_obj` will be `null` (if I remember correctly).
  • I searched the entire script for $_zp_current_admin_obj and Zenphoto_Administrator, and found neither one. What am I missing?
  • acrylian Administrator, Developer
    Well, the global variable kagutsuchi meant is `$_zp_current_admin`. The class he referred to is `Zenphoto_Authority` but that is only in the nightly build due to a change of authorization handling.
  • Ohh, sorry, I forgot that isn't in 1.2.9. acrylian is right.
  • Let me make sure that everything is clear to you.

    With Zenphoto 1.2.9 and previous there is a global array named`$_zp_current_admin`. There are indices for `id` and for `user` so you could get either to put in the template but I would recommend against the `id` and for the `user` element.

    However, once Zenphoto 1.3 is released, this variable will no longer exist as we are moving user references to an object model. With Zenphoto 1.3 you would have to change your theme to use the object method `$_zp_durrent_admin_obj->getUser()`.
  • Thank you SO MUCH! I truly appreciate the assistance!
Sign In or Register to comment.