View Full Version : /me support?
Outlaw Mantis
08-23-2016, 10:41 PM
Back on my MyBB board I had support for /me. For instance...
* Outlaw Mantis is eating a sandwich
Becomes...
Outlaw Mantis is eating a sandwich
Kind of pointless but fun feature. I can't find such a plugin. Is it possible on vBulletin? I know it probably is with BBcode but that's a bit cumbersome for a lot of users. :p
MarkFL
08-23-2016, 11:06 PM
That would be easy to do with a plugin...do you want the string /me to be changed to the username of the author of the post, or to the name of the user viewing the post?
--------------- Added 1472006810 at 1472006810 ---------------
To have "/me" replaced with the username of the post author and "/you" replaced with the username of the user viewing the post, create a plugin hooked at "postbit_display_complete" with the PHP code:
$post['message'] = str_replace(array('/me', '/you'), array($post['username'], $vbulletin->userinfo['username']), $post['message']);
Outlaw Mantis
08-24-2016, 01:16 AM
* Outlaw Mantis works great. I'm just waiting on another member to test /you. One thing is that the /you text appears blank to the poster, but that's no big deal if it works with other members.
Thanks, you're a genius. :D
MarkFL
08-24-2016, 01:18 AM
The string "/you" should show your username, even if you are the author of the post. That's what it does on my local dev site at least. :)
Outlaw Mantis
08-24-2016, 01:30 AM
Could it be to do with the execution order?
https://vborg.vbsupport.ru/external/2016/08/3.jpg
https://vborg.vbsupport.ru/external/2016/08/4.jpg
Knowing me I've done something stupid. :p
MarkFL
08-24-2016, 02:31 AM
I used the default of 5. :)
--------------- Added 1472022341 at 1472022341 ---------------
This plugin code is more robust:
$post['message'] .= ' ';
$post['message'] = preg_replace('/\/you([^A-Za-z_])/i', $vbulletin->userinfo['username'] . "$1", $post['message']);
$post['message'] = preg_replace('/\/me([^A-Za-z_])/i', $post['username'] . "$1", $post['message']);
It will ignore strings like "/meat" and "/yourname" for example. :)
Outlaw Mantis
08-24-2016, 06:07 PM
I updated the code, but the problem persists. I'll PM you a link so perhaps you can inspect the source. Thanks.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.