PDA

View Full Version : So I'm trying to setup a hook on fetch_musername


DISLEX
03-03-2009, 09:42 PM
And when the user matches certain characteristics, I force-change their musername to a different style. Problem is, when I do that, it changes it for EVERYONE. Makes no sense to me...

This is the plugin on the hook:


if (is_member_of($vbulletin->userinfo, 31))
{
$user[musername] = "<strong><span style='color: #FF66FF'>" . $username . "</span></strong>";
}


I know that I could setup a style for usergroup 31, this is only test code. I want to expand upon that if(). But the problem is, it applies this to everyone, not just the users in group 31. How is that even possible? I thought it had something to do with the goofy static $hook_code junk inside functions.php, so I replaced it with a normal hook call, but that didn't change anything.

Any ideas?

Dismounted
03-05-2009, 05:05 AM
What hook are you placing this in?

Lynne
03-05-2009, 03:00 PM
Your condition says "if you the viewer are a member of group 31, then change....". So yes, if you the viewer are a member of group 31, then all the usernames will be changed.

DISLEX
03-05-2009, 10:27 PM
to clarify, I want it to only work for members of usergroup 31.

however, it does it for EVERY single user, regardless of usergroup... I don't understand how that's possible.

I'm playing it under the hook fetch_musername.

Lynne
03-06-2009, 01:13 AM
There is a difference between the *viewer* of the page being a member of group 31, and the page/post belonging to a member of group 31. Your condition is for the first - the viewer of the page. "if the viewer of the page is in group 31, change the username in this way" either all user names on the page will be changed, or they won't - depending on the group the *viewer* is a member of.

If you are talking about a showthread page, and want the *posters* username to change based on whether the *poster* is in usergroup 31 or not (who cares what the usergroup id of the viewer is), then that is a different condition - you would probably use the variable $user['usergroupid'] in the condition.

Dismounted
03-06-2009, 03:50 AM
If you are talking about a showthread page, and want the *posters* username to change based on whether the *poster* is in usergroup 31 or not (who cares what the usergroup id of the viewer is), then that is a different condition - you would probably use the variable $user['usergroupid'] in the condition.
On showthread, you would use $post ;).