PDA

View Full Version : Plugin on fetch_musername


James Birkett
07-09-2010, 11:40 AM
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:

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:
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 1278698556 at 1278698556 ---------------

Bump.

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

BirdOPrey5
07-10-2010, 11: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, 10: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, 03:30 PM
$bbuserinfo['filedX'] should pull the profile field X for that user.

James Birkett
07-11-2010, 04:54 PM
I removed the conditional, leaving my code as:

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, 05: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, 05:36 PM
Yeah, the debug mode should list the variables being called on that page.

James Birkett
07-12-2010, 10: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, 08:53 AM
Which username on a page like for example forumdisplay would not show?

James Birkett
07-13-2010, 09: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, 05: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, 01: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, 01: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, 02:57 PM
Hmm, would I be able to run the query on the hook?

Guest190829
07-14-2010, 03: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.