PDA

View Full Version : Calling out users in thread titles/announcements


MariahMan
11-24-2007, 05:50 AM
I want to announce some features to my member and was wondering how i could do something like:
"Hey ____! Are you on the member map?"

With the blank being their username to catch their attention. I thought i could do it using the vbulletin phrases and did "Hey $username! Are you on the member map?" but i got exactly that. Could you guys let me know the proper way to do this?

Thanks in advance,

-Ryan

Opserty
11-24-2007, 11:53 AM
I doubt you can actually set it in a thread title, since they are stored as in the database and not parsed by any sort of code. There are a number of ways that you may be able to do this, one option would be to:

Create the new thread with the content and title of whatever you would like. (Note: The thread title will be show to guests so make sure it is appropriate)

View the thread and make a note of the threadid it will be the number at the end of the showthread.php URL. (For example: https://vborg.vbsupport.ru/showthread.php?t=163489 it is the number in bold)

Go to the Plugin Manager in the AdminCP and create a new plugin for "threadbit_display" and use the following PHP code:

if(intval($thread['threadid']) == 8 && $vbulletin->userinfo['userid'])
{
$thread['threadtitle'] = 'Hey '. $vbulletin->userinfo['username'] .'! Are you on the member map?';
}

Remember to change the number 8 to your threadid which you found in step 2

I'm not sure how this will affect performance though since you will be running this check quite often, I don't know if there is a more efficient way to do this.

Mark.B
11-24-2007, 12:03 PM
Unduly complex.....there *is* a way to do it easily with a plugin.

*This code is NOT my own, it is posted elsewhere on vbulletin.org, but I have not managed to find it again.

Create a new plugin as follows:

Product: vBulletin
Hook Location: global_complete
Title: Whatever you want to call it
$output = str_replace('[username]', $vbulletin->userinfo['username'], $output);

Now you simply start a thread with [username] in the title and everyone who views it will see their own username there.

Opserty
11-24-2007, 12:21 PM
Won't that also leave it open for people to use wherever they please? For example signatures/posts/threads. I know there isn't much harm in letting other people use the markup but I'd think it would be better to restrict it somewhat.

Mark.B
11-24-2007, 12:34 PM
Yes, that is true, it works anywhere and for anyone.

I daresay there will be ways of easily adapting that code to work only in specific circumstances, but I'm no coder so I can't do that.

Of course, other users would need to know the code that generates it, and you can easily amend it from [username] to something completely different just by changing the code I posted.

I used it on my forums a couple of times as a complete joke. It's quite tricky for an average user to suss it out, as it doesn't even show the tag if you quote or edit something. Nobody from my site sussed it, although I cannot say how much anyone was really that bothered!

MariahMan
11-24-2007, 06:14 PM
Thanks guys for your responses. I went ahead and used your method Mark B because it was the simplest and did the job, but thanks anyways Osperty. Thanks for helping me out, that did the job perfectly in both announcements and thread titles.

Osperty does bring up an important point that this feature can now be utilized by everyone on your board. I personally am not worried about it because my board is an owners club for a specific boat brand and most of them have had troubles just figuring out how to add photos to the gallery let alone figuring this out.

Thanks guys!