Hey,
I have been looking at the idea of adding user log-in to the site so I can do all sorts of things such as:
- greet users on the main site
- display news articles in advance to registered users
- allow registered users the chance to suppress banner ads
- only allow guests to view 10 pages per session before 'lockdown'
Since my site uses SMF, I am sure there are lots of elements that I can use, namely the user login function to allow me to identify users and let them change their options via another table on the site.
First steps first - can anyone give me some pointers on how to integrate the forum login and apply it to my site?
TIA!
Just use SSI.php
Cheers - I checked it out but couldn't figure out how that handles log-in to the site!
Ultimately, I would like to have a table containing user preferences for the site (such as alternate templates, advertising off, new article notification on) that would be set by a user and stored against their profile.
I guess I can do my requests
Quote
- display news articles in advance to registered users
- only allow guests to view 10 pages per session before 'lockdown'
by something simple like
if (!$context['user']['name']) {
show all current articles
} else
// user must be a guest
{
- don't show anything added in the last week
- start couting page views until 10 then ask users to register!
}
Does that make sense?
You'll want to look into session variables and the like; they're part of what you'll need.
Theme options can actually be used this way, but there's currently... not a *ton* of documentation on how to do them from SSI.
-[Unknown]
Thanks.
I seem to have it working to my satisfaction. I guess it's a faily low level check and not secure so as long as I don't make any security specific elements subject to the checks, I think I am cooking.
// include SMF SSI
require_once('../forum/SSI.php');
//check if the user is a guest or not
if ($context['user']['is_guest']) {
do some guesty stuff like limit the number of clicks they can make and stop them accessing the latest two articles
} else {
this is probably a user :), or a reasonable hacker ::), so just let them click through the site and view the lastest bits!
}
Pretty basic but it's added a whole dimension to the site for me and actaully incentivised sign up, which was my goal.
I have also added the simple check
if ($context['user']['name']=="MyUserName") {
show some specific stuff for me
make sure it's fairly innocent, like time to create page, page hits, user rating on that article and simple 'private' stats
}
Job's a good 'un!
Any comments?
See it in action at www.gravity-slaves.co.uk