PDA

View Full Version : Restrict/allow users/groups - non vb pages


VirtualBurn
07-30-2005, 10:00 PM
This hack will enable you to;

Stop Guests viewing non-vb pages
Stop Registered users viewing non-vb pages
Prompt with custom information
Allow 'specified' Group to access


For example:

This code stops my guests (ID:0) and my registered users (ID:2) from accesing the non-vb pages but with let the 'Premium Member' group (ID:9) walk right in.

################################################## ##

1. Create new phrase [ACP --> Lang & Phrases --> Phrase Manager --> Add New Phrase]

Phrase Type: Permissions
Varname: nonvb_restrict
Text: Your Message

e.g.Ticket support & Live support is an advanced feature only available to 'Premium Members'.<br /><br />
Please use the subscription service to enable this feature.

################################################## ##

2. Create new Template [ACP --> Styles & Templates --> Style Manager --> Add new template]

Style: Default style
Title: nonvb_restrict
template: Copy below$stylevar[htmldoctype]
<html id="vb" dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle] - $pagetitle</title>
$headinclude
</head>
<body>
$header
$navbar

<table border="2" width="100%" cellspacing="1" cellpadding="1" >
<tr>
<td class="tcat">
Notice!
</td>
</tr>
<tr>
<td class="alt1" align="center"><br />
$vbphrase[nonvb_restrict]
<br /><br />
</td></tr>
</table>

$footer
</body>
</html>

################################################## ##

3. Protect Pages

In each of the non-vb pages you wish to protect find:require_once("./global.php");
and add the following code after:// ## NONVB_RESTRICT ##



if ($bbuserinfo['userid'] == 0 or $bbuserinfo['usergroupid'] == 2 and !is_member_of($bbuserinfo, 9))

{
eval('print_output("' . fetch_template('nonvb_restrict') . '");');
}

// ## END OF NONVB_RESTRICT

change the numbers in red as you desire.

0 = user ID 'Guest'
2 = group ID 'Registered'
9 = group ID 'Premium'


This has been tested, implemented and working.

Original code by 'Gary King' although his hack was different, various questions and suggestions throughout the thread prompted me to put this together.

Corriewf
08-01-2005, 04:48 AM
AWESOME JOB! I have an irc chat page which is not integrated with vb so this helps alot.

Corriewf
08-01-2005, 04:49 AM
Oh and could you please attach a zip file with the instructions please?

VirtualBurn
08-01-2005, 11:55 PM
All the instructions are above.

That is the same reason I put this together, I have a live support page which uses PJirc, I also use it to restrict groups to the ticket support system.

Once you have configured the last bit of code, you can insert it into any of your vb or non-vb pages so they will see your custom message instead of the standard vb 'you do not have permission to view this page'

Adrian Schneider
08-02-2005, 12:34 AM
Just a note:

You can remove:
$membergroups = explode(',',$bbuserinfo[membergroupids]);
and replace!array_search(9,$membergroups)
with
!is_member_of($bbuserinfo, 9)
as vBulletin does this for you. :)

VirtualBurn
08-02-2005, 01:34 AM
That's real good of you to advise some changes, thanks alot. :)