vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Action based on condition (https://vborg.vbsupport.ru/showthread.php?t=135957)

mistyPotato 01-09-2007 12:45 AM

Action based on condition
 
Can someone tell me how to exclude an action (or line(s)) in a vBulletin script page such as in index.php by allowing only a paricular user or administrator ?

For example......

<if $Username="Administrator">
This is the line I want to be conditionally executed
</if>

In the above example, I ONLY want the red line to be executed if the user is Administrator.
I need some way to exclude a line of the script UNLESS it's the administrator(s) or a particular members who IS the adminstrator.

What I don't know is what variables are stored in memory and how to use them in a conditional statement like this.

Thanks

Kirk Y 01-09-2007 12:52 AM

Are you using these in a PHP file or in a template?

If you're straight-up editing a PHP file, you might want to consider using vBulletin's Plugin System rather than directly modifying your Index.php file -- but, I'll show you anyway as it's the same concept in either option.

PHP Code:

if (is_member_of($vbulletin->userinfo,1,2,3)) {
// php code to execute if user is in usergroupid 1, 2, or 3


PHP Code:

if ($vbulletin->userinfo['username'] == 'JohnDoe') {
// php code to execute if the username is "JohnDoe"



mistyPotato 01-09-2007 02:08 AM

For some reason it's not working?
I'm working inside vbulletin's admin panel.

Here's the actual code in the template....

<if ($vbulletin->userinfo['username']=='JohnDoe')>

<td class="vbmenu_control"><a href="memberlist.php$session[sessionurl_q]">$vbphrase[members_list]</a></td>

</if>


And here's what I get when I view the Source in a browser....

<if (Array['username']='JohnDoe')>

<td class="vbmenu_control"><a href="memberlist.php">Members List</a></td>

</if>


But for some reason, it still shows the code no matter what.
I'm baffled. If I comment out the code, it no longer shows (as expected).

any ideas?

Thanks

calorie 01-09-2007 02:30 AM

In vB templates do like this:
Code:

<if condition="$bbuserinfo[username] == 'JohnDoe'">
        <td class="vbmenu_control"><a href="memberlist.php$session[sessionurl_q]">$vbphrase[members_list]</a></td>
</if>

In PHP files do as in post two.

mistyPotato 01-09-2007 03:17 AM

Thank calorie !!!!
It worked !!!!! :)

HUG


Thanks also for your help acidburn.
For some reason I just could quite get it to work with the code you posted :confused:

Kirk Y 01-09-2007 08:01 PM

The code I posted was for use in either PHP Files or Plugins, sorry I wasn't more specific.

Stifler 01-14-2007 12:04 PM

Quote:

Originally Posted by acidburn0520 (Post 1154185)

PHP Code:

if (is_member_of($vbulletin->userinfo,1,2,3)) {
// php code to execute if user is in usergroupid 1, 2, or 3



would I be able to use that in a template field in vbulletin 3.5?

Kirk Y 01-14-2007 03:46 PM

If you're using it in a template:

Code:

<if condition="is_member_of($bbuserinfo,1,2,3)">
Code to execute if User is a Member of Usergroups 1, 2, or 3
</if>


mrkhm 01-28-2007 06:07 AM

acidburn0520 you hit the nail right on the head!!!! thats what works!!!!


All times are GMT. The time now is 08:59 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
  • Page Generation 0.01603 seconds
  • Memory Usage 1,734KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete