Looking to use SMF member for site too

Started by mrandall131, December 16, 2005, 08:34:43 PM

Previous topic - Next topic

mrandall131

I am looking to integrate the members / permissions into my site.  I would like to let people register on the main site (instead of just the forum), and use the group permissions from my forum to allow or disallow certain pages in my site. 

I think I am close to the registration part, but am really struggling (just a beginner).  I am also trying to understand the cookie that SMF creates for I can use that to.

I was wondering if someone can point me in the right direction, maybe? 

Dean Williams

firstly you will need to include the SSI.php file.

lets say your site is at location: forum/website/ and your forums is at: forum/ then we do this:

<?php include('../SSI.php'); ?>

Now that we have that we can start to check for user groups with alot of ease!

Admin:
if ($context['user']['is_admin'])
{
//this guy is an admin!
}
code]

[b]Mod:[/b]
[code]if ($context['user']['is_mod])
{
//this guy is an mod!
}
code]
[b]guest:[/b]
[code]if ($context['user']['is_guest])
{
//this guy is an guest!
}
code]

I'm not too sure about individual member groups yet, let me read up on that and post soon.
[/code][/code]

mrandall131

#2
Sweet, thanks!  If I want to check for custom groups, I assume I just substitute the group ID into those statements too?

I posted this question in another spot, and got no answer.  Maybe you could help on this one too?  It has to do with the registration of people from my site.  I wrote the script and got it to add a person to the smf_members table.  I went to the DB and I saw the user added.  But, when I go to try and log in with that account, I get an error.  First, it asks me to re-enter the password because password security has been upgraded.  When I enter the password again, it says password incorrect?

When I added the user to the DB, I used the password() function.  Is this correct?  Also, what am I missing to make the users active?

Oldiesmann

#3
If you want to check for custom groups, use the "in_array" function and look at $user_info['groups']:

One group:
if(in_array('groupidgoeshere', $user_info['groups']))
{
    // They're in this group
}


Multiple groups:
if(in_array(array('group1id', 'group2id', ...), $user_info['groups']))
{
    // They're in one of those groups
}
else
{
    // They're not in one of those groups
}


It's generally best to use SMF's built-in registration system. Since you can check permissions and such by calling SSI.php, there's no real need to have your own custom registration system.

The "password security has been upgraded" message is generated mainly when a user logs in to a board for the first time after it's been upgraded from 1.0.5 to 1.1 - the password hashing method is different in 1.1, so SMF needs to make sure that you're entering the correct password before it can re-hash it. SMF must have thought that the password was md5-encrypted or it wouldn't have given you that message.

SMF will not be able to understand passwords encrypted using MySQL's PASSWORD() function, so that's why it gave you the error after you entered the password again.
Michael Eshom
Christian Metal Fans

mrandall131

This is awsome info guys, thanks! 

Ok, I'll stick to using SMF's registration.  I guess I'll look at the register PHP file.  I still want to try and integrate it with my main sight, or at least if the guest registers in the main site, for them to stay there and not get directed into the forum.

Guess I now have a lot of work to do since I have this info, thanks again!!

mrandall131

#5
Is there anyway to not redirect to the forum if I use SSI login / logout?

Duh, I see it now.

jonde99


mrandall131

If you look at the function in SSI.php, you can pass in the url to redirect to.   ;D

Advertisement: