Simple Machines Community Forum

General Community => Scripting Help => Aiheen aloitti: velkymx - marraskuu 21, 2007, 01:19:47 AP

Otsikko: Getting User ID
Kirjoitti: velkymx - marraskuu 21, 2007, 01:19:47 AP
I want to integrate the SMF login and use the user id for other areas of my site.

For example: a forum member could post a want ad

What is the session variable I need to call do get user id???
Otsikko: Re: Getting User ID
Kirjoitti: codenaught - marraskuu 21, 2007, 01:38:06 AP
Well I don't think the ID is stored in any $_SESSION variable. If you load SSI.php you can use SMF's variables, of which one of them is $context['user']['id'], which returns the ID of the current member.

There is an ssi_login() function too that can print out a login box on your site.

http://docs.simplemachines.org/index.php?topic=400.0
Otsikko: Re: Getting User ID
Kirjoitti: velkymx - marraskuu 21, 2007, 01:42:02 AP
How do I include the SSI? Just include it??
Otsikko: Re: Getting User ID
Kirjoitti: codenaught - marraskuu 21, 2007, 01:46:30 AP
As stated in that document:

LainaaPHP Setup
Now that we have established you have a compatible web page setup, we need to add a line of code to every page where you wish to add any Forum (http://docs.simplemachines.org/index.php?topic=201.0) information and statistics on your website. Pages with *.shtml extensions do not require this set up and can skip to the next section! To use SSI.php in your webpage, add at the very top of your page before the <html> tag on line 1:

<?php require("/path/to/forum/SSI.php"); ?>

This may be slightly different on your Forum (http://docs.simplemachines.org/index.php?topic=201.0) installation depending on the location of your SMF boards. If you are unsure, you can run ssi_examples.php or ssi_examples.shtml from your own Forum (http://docs.simplemachines.org/index.php?topic=201.0) directory on your website, which will give the correct code for your personal requirements.
So basically you would want to require it at the top of the file.
Otsikko: Re: Getting User ID
Kirjoitti: velkymx - marraskuu 21, 2007, 01:53:43 AP
Fantastic. Thank you!