vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   /me support? (https://vborg.vbsupport.ru/showthread.php?t=323331)

Outlaw Mantis 08-23-2016 10:41 PM

/me support?
 
Back on my MyBB board I had support for /me. For instance...

[high]* Outlaw Mantis is eating a sandwich
[/high]
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 [DATE]1472006810[/DATE] at [TIME]1472006810[/TIME] ---------------

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:

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

[high]* 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.[/high]

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 [DATE]1472022341[/DATE] at [TIME]1472022341[/TIME] ---------------

This plugin code is more robust:

PHP Code:

$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.


All times are GMT. The time now is 01:52 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.00960 seconds
  • Memory Usage 1,729KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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