Restricting access for quizzes to a usergroup

All web design discussion, including Ultimate Quiz MOD support.

Moderator: CricketMX Forum Moderators

Post Reply
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

I'll split this into a new topic over the next day or so. :)

The coding of it is not too difficult, providing you don't mind missing out on the ACP side of it (ie. it will be very quick to just put something in the code saying "only allow access if user is from usergroup X" but would take considerably longer to build ACP options for it too).

Would that be suitable?
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

That's perfect. Got no problem with that and I really appreciate it!
If you don't ask...
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

What is the ID number of the usergroup you want to allow access? If you go to the usergroup page it should be the ID in the address bar.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

http://www.screwballscrabble.co.uk/forum/groupcp.php?g=292&sid=33299dffb5976f99193af108516bdcd4

That's the URL address of the usergroup (Access All Areas) page but can't make head or tail of what the ID is from that though. 292? 29?
If you don't ask...
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

Think I've cracked it.... after much fiddling. Inserted the following code into quiz.php:

Code: Select all

      $groupid=10; // ID of group whitch can enter to players database 
      $us_id=$userdata['user_id']; //ID of the current logged in user 

      if ($userdata['user_level'] != ADMIN){ 
      $sql = "SELECT group_id,user_id 
      FROM phpbb_user_group 
      WHERE group_id=".$groupid." AND user_id=".$us_id; 

      if( !($result = $db->sql_query($sql)) ){ 
              message_die(GENERAL_ERROR, 'Could not Check for group membership', '', __LINE__, __FILE__, $sql);} 
      $row = $db->sql_fetchrow($result); 

      if ($row['user_id']==''){ 
      message_die(GENERAL_ERROR, 'Sorry - You can not access this page.', '', '', ''); 
      } 
      } 
I gave the wrong URL as UQM is currently installed at my test site and the actual user group ID is 10. (That URL was for live forum lol).
If you don't ask...
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

That looks fine to me! Well done! :)

Congratulations on your 50 posts milestone too :D
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
quahappy
Happy, not Quappy
Happy, not Quappy
Posts: 2266
Joined: Fri Oct 10, 2008 8:56 pm
Location: South Yorkshire, UK

Thanks battye! I need to do same for Hangman MOD so guess what I'm doing later lol.

Over 50 posts already?! Crikey! :lol:

I like the various ranks here - Greenhorn was one (my surname is Green pmsl). First rank at my site is "Screwball virgin". Always causes a laugh and remarks from newbies. lol
If you don't ask...
Post Reply