Announcement

#1 2014-10-02 21:51:46

Blackbird
Member
2014-10-02
2

[SQL/PHP] Finding the user_id of the user that executes the script

Hello,

I got a question about a SQL-script I want to build. Let me give you a quick introduction to what my plans are:

- Ik heb inmiddels een Piwigo-galerij gebouwd voor een goede vriendin van mij, waarvoor ik de site beheer. Zij is fotografe en biedt fotoshoots aan tegen betaling. Mensen die een fotoshoot hebben gehad krijgen de foto's van de fotoshoot gratis, maar dan wel slechts tot middelgroot formaat en met een watermerk.
- I built a Piwigo Gallery for a good friend of me. She's a semi-professional photographer and needed a reliable website. She's offering photoshoots to people in exchange for payment. People that got a photoshoot with her will get all the photos by the Gallery, but limited to a max of medium size and with a watermark. If they want printed photos (without watermark) or enlargements, they should order those by a special ordering page. As such a thing doesn't exist I have to script that SQL-query myself. That's no problem, but I need the "user_id" first to check to what categories and photos the person has access.

So, what I need, is the user_id variable contents when a user gets on the ordering page.

I hope you guys understand it all, haha. If not, don't hesitate to ask!

I hope to hear from you soon!


Piwigo version: 2.7
PHP version: native 5.4
MySQL version: 5.5.37-cll
Piwigo URL: http://www.nienkeklijn-fotografie.nl/gallery/

Offline

 

#2 2014-10-02 22:00:34

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [SQL/PHP] Finding the user_id of the user that executes the script

Hi Blackbird,

You have the current user id in $user['id'] (you can add "global $user;" at the beginning of your function if you're in a function)

Offline

 

#3 2014-10-02 22:22:12

Blackbird
Member
2014-10-02
2

Re: [SQL/PHP] Finding the user_id of the user that executes the script

plg wrote:

Hi Blackbird,

You have the current user id in $user['id'] (you can add "global $user;" at the beginning of your function if you're in a function)

Thanks! So If I'm right $user is an array here with the id in it? Can I exclude this Id like this?:

Code:

<?php

$user_id = $user{'id'};

?>

Then, user_id contains the user if I'm right? (It's some time ago I practised with this PHP). Thanks again!!

Last edited by Blackbird (2014-10-02 22:23:30)

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact