![]() |
how is this simply done ?
hi,
how do i restrict a php to only a certain user group can use it, and others get a custom error message ( using a template ) ? there group i want to only access this is: usergroupid=2 could anyone help me please ? thanks for your time |
this is how you do it Vinney ;)
PHP Code:
and place the error message in the template call the template whatever you want (ie. error_restricted) if you call it error_restricted then you must change eval the error template accordingly... ie: PHP Code:
g-force2k2 |
btw Vinney just place the first coding under the:
PHP Code:
g-force2k2 |
this is what i've got so far ... it works.
<?php error_reporting(7); include ("../../mainfile.php"); $index = 1; global $Pmenu,$breadcrumb; $Pmenu=""; $breadcrumb="Account Activation"; $defaultmessage = "Your message here... \n\n - $bbuserinfo[username]"; $defaultemail = "$bbuserinfo[email]"; getvbpvars(); include("header.php"); //OpenTable(); if (!$bbuserinfo[userid] || $bbuserinfo[usergroupid]==1 || $bbuserinfo[usergroupid]==3 || $bbuserinfo[usergroupid]==11) { eval("dooutput(\"".gettemplate('contact_error')."\ ");"); } else { eval("dooutput(\"".gettemplate('contact')."\");"); } //CloseTable(); include("footer.php"); ?> whats the difference between what i have done and what your saying ? does yours mean : if userid equals 2, get error template ... or does yours mean, if userid equals 2, continue ? |
Vinny find this code:
PHP Code:
PHP Code:
then under that add my code... all my code states is that if the user trying to access the script isn't in the usergroupid 2 then they will recieve the error ;) regards hope that helps... g-force2k2 |
and .... sorry ( am a newbie - am just trying to get my head around this )
1. using your example, how would allow multiple usergroups ? -------------------------------- 2. in my example there is a line : if (!$bbuserinfo[userid] || $bbuserinfo[usergroupid]==1 || $bbuserinfo[usergroupid]==3 || $bbuserinfo[usergroupid]==11) { what is the significance of - if (!$bbuserinfo[userid] being there ? is that needed ? thanks again. |
Quote:
my example does work. my require('./global.php'); is in the mainfile.php, that isn't an issue. |
hey np Vinney thats why im here to help :p
what do you mean allow multiple usergroups? if you want the script restricted to just usergroupid 2 then replace: PHP Code:
PHP Code:
as for the PHP Code:
g-force2k2 |
Quote:
g-force2k |
ok
this works too : <?php error_reporting(7); include ("../../mainfile.php"); $index = 1; global $Pmenu,$breadcrumb; $Pmenu=""; $breadcrumb="Account Activation"; $defaultmessage = "Your message here... \n\n - $bbuserinfo[username]"; $defaultemail = "$bbuserinfo[email]"; getvbpvars(); include("header.php"); //OpenTable(); if (!$bbuserinfo[usergroupid]==1 || $bbuserinfo[usergroupid]==3 || $bbuserinfo[usergroupid]==11) { eval("dooutput(\"".gettemplate('contact_error')."\ ");"); } else { eval("dooutput(\"".gettemplate('contact')."\");"); } //CloseTable(); include("footer.php"); ?> |
my example :
if (!$bbuserinfo[usergroupid]==1 || $bbuserinfo[usergroupid]==3 || $bbuserinfo[usergroupid]==11) { your example: if($bbuserinfo[usergroupid] != 1 || $bbuserinfo[usergroupid] != 3 || $bbuserinfo[usergroupid] != 11) { ( can the above be done ? - why does mine have double '==' and yours dont. - can you explain this please ) BTW am restrcing it to groupid 1, 3 and 11 , anthing else gets the error. ps. Does the rest of my script too correct ( btw is all does work - am just wondering if i have done anything funny or wondering if there is a 'better' way to get the same result. Thanks g-force2k , you have been loads of help. |
well the Vinney your code is correct... all mine stated was that if usergroupid isn't equal to two then show the error...
the difference btw the codes is that: == <-- means is equal to != <-- means is not equal to btw your code looks fine :) g-force2k2 |
ok am trying to get too big for my boots here, i cant seem to get this to work:
know why ? <?php error_reporting(7); include ("../../mainfile.php"); $index = 1; global $Pmenu,$breadcrumb; $Pmenu=""; $breadcrumb="Account Activation"; $defaultmessage = "Your message here... \n\n - $bbuserinfo[username]"; $defaultemail = "$bbuserinfo[email]"; $unwantedgroups = array('1', '6', '11'); getvbpvars(); include("header.php"); //OpenTable(); if ($bbuserinfo[usergroupid] == $unwantedgroups) { eval("dooutput(\"".gettemplate('contact_error')."\ ");"); } else { eval("dooutput(\"".gettemplate('contact')."\");"); } //CloseTable(); include("footer.php"); ?> am trying to use an array, to get the same result. |
Vinny you'll probably have to explode the array... im not that great with arrays and exploding :P so i suggest just using the way you had had it :) regards...
g-force2k2 |
All times are GMT. The time now is 05:02 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|