![]() |
How to use "if" condition?
I have a plugin that inserts PHP code on all pages to check a user's IP address. What I want to do exclude it from checking administrator's IPs.
The plugin looks like this: HTML Code:
<dependencies /> <vb:if condition="is_member_of($bbuserinfo, 1,2,3,4,8,17,19,20,26,15,22,16,14,18,21)"> But if I insert that in the xml file when adding the product/plugin it gives me a mysql error and doesn't work. Any ideas? Thank you! -Jennifer |
Wrap the plugin code with:
PHP Code:
|
<vb:if> is for use in templates. Are you needing the IF statement in a template or in php code?
If using it in the php plugin, use it as MarkFL stated above. |
Quote:
I've tried a few times but can't seem to know exactly where I'm supposed to wrap the code. I keep breaking something. This is the entire XML file... HTML Code:
<?xml version="1.0" encoding="ISO-8859-1"?> |
Change it to read:
HTML Code:
<?xml version="1.0" encoding="ISO-8859-1"?> |
Quote:
--------------- Added [DATE]1447265522[/DATE] at [TIME]1447265522[/TIME] --------------- I just realized today that the code isn't working :( It doensn't return any errors but the code isn't executing for any of the usergroups in the array. If anyone has any ideas I'd greatly appreciate it. Thank you! |
Quote:
Code:
if (file_exists($CWD.'/blockscript/detector.php')) { Code:
ob_start(); Unless you are using an external (to VB) file, $CWD should be the root VB folder, so you should not need to check it several times. |
Quote:
HTML Code:
<?xml version="1.0" encoding="ISO-8859-1"?> |
Quote:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> Code:
<?xml version="1.0" encoding="ISO-8859-1"?> Then in the template, where you want the included file to appear you put this: Code:
{vb:raw includedphp} |
Thanks for the response.
Just to say: The original template I provided was working/already in use. The only thing that seemed to stop it from working altogether was the inclusion of the: HTML Code:
if (is_member_of($vbulletin->userinfo, array(1,2,3,4,8,17,19,20,26,15,22,16,14,18,21))) Thank you! |
You might want to read the VB Manual or ask for someone to create the plugin for you at this point. We have basically written everything except the plugin(s) for auto template edits
|
Thanks for the response.
Just to make sure we're on the same page: The original code I originally supplied is already an existing plugin that automatically inserts itself into every page/template on the site. So, is merely adding the usergroup restriction reversing the plugins existing ability of being inserted into every page? Thank you! |
Quote:
|
Quote:
This is the specific code with conditional included I'm talking about: HTML Code:
<?xml version="1.0" encoding="ISO-8859-1"?> |
Change the hook location to global_start as suggested by Dragonsys because $vbulletin->userinfo is not defined at init_startup. :)
|
But beware: global_start is not being executed in the CMS.
|
Quote:
|
All times are GMT. The time now is 12:51 PM. |
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:
|