Page 1 of 1

Restricting access for quizzes to a usergroup

Posted: Sun Nov 02, 2008 12:54 am
by battye
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?

Re: Dynamic timer

Posted: Sun Nov 02, 2008 7:56 am
by quahappy
That's perfect. Got no problem with that and I really appreciate it!

Re: Restricting access for quizzes to a usergroup

Posted: Sun Nov 02, 2008 1:20 pm
by battye
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.

Re: Restricting access for quizzes to a usergroup

Posted: Sun Nov 02, 2008 3:34 pm
by quahappy
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?

Re: Restricting access for quizzes to a usergroup

Posted: Sun Nov 02, 2008 6:52 pm
by quahappy
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).

Re: Restricting access for quizzes to a usergroup

Posted: Mon Nov 03, 2008 3:56 am
by battye
That looks fine to me! Well done! :)

Congratulations on your 50 posts milestone too :D

Re: Restricting access for quizzes to a usergroup

Posted: Mon Nov 03, 2008 5:44 pm
by quahappy
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