vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Plugin on fetch_musername (https://vborg.vbsupport.ru/showthread.php?t=246208)

James Birkett 07-09-2010 10:40 AM

Plugin on fetch_musername
 
I have a plugin running on the fetch_musername hook that changes the username mark-up depending on a selection in their profile.

The plugin is:
PHP Code:

if((!empty($user['field14'])) && ($user['displaygroupid'] == 40)){
    switch(
$user['field14']){
    case 
'Ice Blue':
    
$user['musername'] = "<span style=\"color:#74BBFB; font-weight:bold;\">".$user['username']."</span>";
    break;
    case 
'Tree Green':
    
$user['musername'] = "<span style=\"color:#9CDE7B; font-weight:bold;\">".$user['username']."</span>";
    break;
    case 
'Orange':
    
$user['musername'] = "<span style=\"color:#F38330; font-weight:bold;\">".$user['username']."</span>";
    break;
    case 
'Pink':
    
$user['musername'] = "<span style=\"color:#EA3884; font-weight:bold;\">".$user['username']."</span>";
    break;
    case 
'Purple':
    
$user['musername'] = "<span style=\"color:#B290C0; font-weight:bold;\">".$user['username']."</span>";
    break;
    }


Now, this plugin works around some areas (profile, posts) but it fails to work on things like visitor messaging and the who's online display block.

Has anyone got any ideas how to fix this?

I'd take a guess that it's because I'm using the $user variable, that isn't globally available... so perhaps I would have to change the conditional too...

Would I have to declare the $post['fieldX'] and $bbuserinfo['fieldX'] in there too?

EDIT: I tried this code too, and it failed to work:
PHP Code:

if((!empty($user['field14'])) && ($user['displaygroupid'] == 40)){
    switch(
$user['field14']){
        case 
'Ice Blue':
        
$user['musername'] = "<span style=\"color:#74BBFB; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Tree Green':
        
$user['musername'] = "<span style=\"color:#9CDE7B; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Orange':
        
$user['musername'] = "<span style=\"color:#F38330; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Pink':
        
$user['musername'] = "<span style=\"color:#EA3884; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Purple':
        
$user['musername'] = "<span style=\"color:#B290C0; font-weight:bold;\">".$user['username']."</span>";
        break;
    }
    switch(
$post['field14']){
        case 
'Ice Blue':
        
$user['musername'] = "<span style=\"color:#74BBFB; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Tree Green':
        
$user['musername'] = "<span style=\"color:#9CDE7B; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Orange':
        
$user['musername'] = "<span style=\"color:#F38330; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Pink':
        
$user['musername'] = "<span style=\"color:#EA3884; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Purple':
        
$user['musername'] = "<span style=\"color:#B290C0; font-weight:bold;\">".$user['username']."</span>";
        break;
    }
    switch(
$bbuserinfo['field14']){
        case 
'Ice Blue':
        
$user['musername'] = "<span style=\"color:#74BBFB; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Tree Green':
        
$user['musername'] = "<span style=\"color:#9CDE7B; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Orange':
        
$user['musername'] = "<span style=\"color:#F38330; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Pink':
        
$user['musername'] = "<span style=\"color:#EA3884; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Purple':
        
$user['musername'] = "<span style=\"color:#B290C0; font-weight:bold;\">".$user['username']."</span>";
        break;
    }


--------------- Added [DATE]1278698556[/DATE] at [TIME]1278698556[/TIME] ---------------

Bump.

Sorry guys, this is something I've been looking at for ages and I can't debug it :(

BirdOPrey5 07-10-2010 10:10 PM

$bbuserinfo is global so it should work anywhere... My guess is in the locations it's not working is because the hook isn't called.

James Birkett 07-11-2010 09:03 AM

I've got debug mode on and the hook is called on Forumdisplay and on visitor messages and there's still no change.

I can't use bbuserinfo in the condition because I need to use $user to grab the profile field.

BirdOPrey5 07-11-2010 02:30 PM

$bbuserinfo['filedX'] should pull the profile field X for that user.

James Birkett 07-11-2010 03:54 PM

I removed the conditional, leaving my code as:

PHP Code:

if($user['displaygroupid'] == 40){
    switch(
$user['field14']){
        case 
'Ice Blue':
        
$user['musername'] = "<span style=\"color:#74BBFB; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Tree Green':
        
$user['musername'] = "<span style=\"color:#9CDE7B; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Orange':
        
$user['musername'] = "<span style=\"color:#F38330; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Pink':
        
$user['musername'] = "<span style=\"color:#EA3884; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Purple':
        
$user['musername'] = "<span style=\"color:#B290C0; font-weight:bold;\">".$user['username']."</span>";
        break;
    }
    switch(
$post['field14']){
        case 
'Ice Blue':
        
$user['musername'] = "<span style=\"color:#74BBFB; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Tree Green':
        
$user['musername'] = "<span style=\"color:#9CDE7B; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Orange':
        
$user['musername'] = "<span style=\"color:#F38330; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Pink':
        
$user['musername'] = "<span style=\"color:#EA3884; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Purple':
        
$user['musername'] = "<span style=\"color:#B290C0; font-weight:bold;\">".$user['username']."</span>";
        break;
    }
    switch(
$bbuserinfo['field14']){
        case 
'Ice Blue':
        
$user['musername'] = "<span style=\"color:#74BBFB; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Tree Green':
        
$user['musername'] = "<span style=\"color:#9CDE7B; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Orange':
        
$user['musername'] = "<span style=\"color:#F38330; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Pink':
        
$user['musername'] = "<span style=\"color:#EA3884; font-weight:bold;\">".$user['username']."</span>";
        break;
        case 
'Purple':
        
$user['musername'] = "<span style=\"color:#B290C0; font-weight:bold;\">".$user['username']."</span>";
        break;
    }


Yet it still doesn't display on forumdisplay, forumhome, visitor messaging etc.

If the $bbuserinfo variable worked, it should work on the switch, yet it doesn't. :(

BirdOPrey5 07-11-2010 04:31 PM

Sorry, I didn't see you tried $bbuserinfo first. :( I wish there was a list of variables and where they are available someplace.

James Birkett 07-11-2010 04:36 PM

Yeah, the debug mode should list the variables being called on that page.

James Birkett 07-12-2010 09:32 PM

Bump (again).

I'm baffled by this one, can anyone else share an insight.

The hook is being called on all of the pages that I require.

Marco van Herwaarden 07-13-2010 07:53 AM

Which username on a page like for example forumdisplay would not show?

James Birkett 07-13-2010 08:13 AM

The username of the user who filled the condition ($user['displaygroupid'] == 40).

I thought I had covered all options by using $post, $user, $bbuserinfo - apparently not!

Marco van Herwaarden 07-14-2010 04:29 AM

On the forumdisplay page there are many usernames shown. Some will use fetch_musername, and some are just displayed without any markup:

- "Welcome <username>" in the header: no markup
- Threadstarter: markup
- Last poster of thread: no markup
- Currently active users: markup

James Birkett 07-14-2010 12:10 PM

I realise that thread authors don't actually show with markup, but the currently active users, what's going on and other pages should change their mark-up based on this hook - and they don't.

Guest190829 07-14-2010 12:41 PM

The issue is most likely that field14 is not being pulled from that database in the sections not displaying markup correctly. For instance, why would the currently active users need to pull custom userfields?

You'll probably have to edit the query on index.php to get the field.

James Birkett 07-14-2010 01:57 PM

Hmm, would I be able to run the query on the hook?

Guest190829 07-14-2010 02:18 PM

*looks at file*

Not the fetch_musername hook but a hook: forumhome_loggedinuser_query ; this of course will only solve the Who's Online markup. You'll have to search for the other queries and see if they have hooks available too.


All times are GMT. The time now is 10:36 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.01666 seconds
  • Memory Usage 1,808KB
  • 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
  • (15)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