Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Dec 2004
Posts: 4
Lurker
Lurker
Offline
Joined: Dec 2004
Posts: 4
I'd like to be able to restrict areas of my site depending on whether a user is a part of a particular group. I dont care whether they login on a special page to enter that area, or if they just piggyback off of their forums login. How can I accomplish this?

Sponsored Links
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
You could start here:

https://www.ubbdev.com/forum/showflat.php/Number/116324

Adding a bit more authentication code could restrict it to certain usergroups. I use it on one site quite a bit for site design consistency


- Allen wavey
- What Drives You?
Joined: Dec 2004
Posts: 4
Lurker
Lurker
Offline
Joined: Dec 2004
Posts: 4
(Referring to generic.php from the above mentioned mod)
Incase anyone wanted the code for how I modified it to do what I wanted...

Of course I started with the line... //DO NOT EDIT THIS SECTION


Code
<br />...<br />// DO NOT EDIT THIS SECTION<br />// Require the library<br />   require ("$threadspath/includes/main.inc.php");<br /><br />   $userob = new user;<br />   $user = $userob -> authenticate("U_Groups");<br />   <br />// --------------------<br />// Authenticate the user<br />$html = new html;<br />if (!$user['U_Username']){<br />	$html -> not_right ($ubbt_lang['NO_AUTH'],$Cat);<br />}<br /><br />$Groups = $user['U_Groups'];<br />if (!$Groups) {<br />	$Groups = "-4-";<br />}<br /><br />// --------------------------------------------------------------<br />$Grouparray = split("-",$Groups);<br />$gsize = sizeof($Grouparray);<br />$g = 0;<br />for ($i=0; $i<=$gsize;$i++) {<br />	if (!isset($Grouparray[$i])) { continue; }<br />	//Change the [5-6] below to whatever range of groups you want to allow through to your template<br />	if (preg_match("/[5-6]/",$Grouparray[$i]))<br />	{<br />		$g = 1;<br />    	continue;<br />	}<br />}<br />if($g == 0){<br />	$html -> not_right($ubbt_lang['BAD_GROUP'],$Cat);<br />}<br /><br />   $html -> send_header($pagetitle,$Cat,0,$user);<br /><br />// ---------------------<br />// Grab the tablewrapper<br />   list($tbopen,$tbclose) = $html -> table_wrapper();<br />	<br />// ***** YOU MAY NEED TO EDIT THE NAME OF THE TEMPLATE ******<br /><br />   	if (!$debug) {<br />   	include("$thispath/templates/$tempstyle/generic.tmpl");<br />	}<br /><br />// Send the footer<br />  $html -> send_footer();<br />?><br />

Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
Here is one I still use on my pages, but it is tailored to only check for one group. That of course can be changed as well if you want to check for multiple groups.

https://www.ubbdev.com/forum/showflat.php?Cat=0&Board=php&Number=120139


Link Copied to Clipboard
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 20240506)