vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Plug-in syntax help (https://vborg.vbsupport.ru/showthread.php?t=221420)

James Birkett 08-21-2009 04:20 PM

Plug-in syntax help
 
I'm trying to create a nice little plug-in to annoy my forum users (I'm so kind, right?).
Anyway: I am having a little trouble with the code.

PHP Code:

if(($user['userid'] != 1) || ($user['userid'] != 2)) {
$user['musername'] = $vbulletin->usergroupcache["$displaygroupid"]['opentag'] . str_shuffle($username) . 
$vbulletin->usergroupcache["$displaygroupid"]['closetag'];


Basically I want to omit user ID 1 AND 2 from the str_shuffle. So basically ID 3 and onwards gets a shuffled username, whereas IDs 1 and 2 don't.

I am going wrong here:
PHP Code:

if(($user['userid'] != 1) || ($user['userid'] != 2)) 

I just can't get the syntax right to omit both.

Lynne 08-21-2009 05:03 PM

It would help if you would tell us the plugin location because maybe you are using the wrong variable? Anyway, try this:
PHP Code:

if (!in_array($user['userid'], array(1,2)) 


Adrian Schneider 08-21-2009 05:07 PM

Use of an array is preferred, but to help you with your original logic:

if userid !=1 and userid != 2

using or means it would always be true

James Birkett 08-21-2009 05:15 PM

Both methods work fine.
I was using the fetch_musername hook.

Thanks to both of you.

Lynne 08-21-2009 06:52 PM

Just a word of caution.... watch it when switching usernames around because PMs may be sent to the wrong person. I switched some around a long time ago as an April Fool's joke and things got a bit messed up there. So, be sure to test this out on your test site and make sure it is working how you want it to in regards to profiles/PMs.

James Birkett 08-21-2009 07:07 PM

I don't think anything on vbulletin uses the markup username does it? I thought it was just for display purposes?
Changing $user['username'] or $username would be stupid indeed. I didn't think markup usernames had anything relying on it in terms of PMs etc..

Lynne 08-21-2009 08:47 PM

You know, it was four years ago that I did this, so I don't remember the particulars. But I do remember the screwed up PMs. Like I said, test it and see what happens.

James Birkett 08-21-2009 09:33 PM

PMs and Profiles work fine.

I appreciate the heads up though - thanks Lynne.


All times are GMT. The time now is 07:01 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
  • Page Generation 0.01165 seconds
  • Memory Usage 1,726KB
  • 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
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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