Like Post
If a specific post was interesting or useful to you, we recommend that you Like that post. It tells the post author, and others, that you found the information valuable. Clicking Like is another way to let others know that you enjoy it without leaving a comment.

Log in to join the conversation and Like this content.
Members Who Like This Post
Gizmo
Total Likes: 1
User Authentication Class #312798 Jan 19th a 10:59 PM
by Ian Spence
Ian Spence
Attached is the file. Rename it user_auth.inc.php and throw it in the includes directory of your forums.

Then just require the file and use it as follows
PHP Code
// Usage:

$userob = new user_auth();

// Am I logged in?
if( $userob->is_logged_in ) {
// I am logged in
}

// Am I in group 3?
if( $userob->in_group( 3 ) ) {
// Why, yes we are
}

// Who cares what group I'm in! I wanna know
// if I can read a topic from forum 7
if( $userob->check_access( 7, "read" ) ) {
// Apparently I can
}

// What if I want to know if I'm an administrator
if( $userob->fields['USER_MEMBERSHIP_LEVEL'] == "Administrator" ) {
// That means I'm teh uber user
}

// Want to create a welcome message?
if( $userob->is_logged_in ) {
if(
$userob->is_banned ) {
echo
"Go away, " . $userob->fields['USER_DISPLAY_NAME'];
} else {
echo
"Welcome, " . $userob->fields['USER_DISPLAY_NAME'];
}
} else {
echo
"Please register";
}


Note that $userob->fields is the same as the $user you've been using before, just wanted to not have two different variables hanging around

If you have any problems, it could be due to some paths being off, but the php error will explain that
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
hatter
hatter
USA
Posts: 69
Joined: January 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)