View Full Version : Hello [username]!
Wherever I put this tag in my title, post or sig your logged in username will appear. If you're not logged in then something else pre-defined will show up.
I have seen this in action on a live board. How can I do it? I searched this forum but I haven't had a lot of luck :(
Thank you.
Andreas
07-29-2005, 05:17 PM
Hookname: global_complete
$output = str_replace('[username]', $vbulletin->userinfo['username'], $output);
Please note that this replace takes place EVERYWHERE.
Ok, couple of questions.
So, I can start a topic that says "Hi [username], how are you today?" and it will output for instance, "Hi KirbyDE, how are you today?"
What file does this go in to?
Andreas
07-29-2005, 05:40 PM
1) Yes
2) No File - Hook global_complete
Thank you :)
What would it display to a user who is not logged in?
How can it be : "Guest" ?
Andreas
07-29-2005, 05:56 PM
Unregistered User or smth. like that.
bchertov
07-29-2005, 06:18 PM
<off topic>
KIRBY!
Please contact me ASAP! I need the a file you changed for me.
It's URGENT!
Barry@waccobb.net
Boofo
07-29-2005, 11:00 PM
How do we make the plug-in for this?
It doesn't work with 3.5.0 RC 1 for me.
Any idea why?
Andreas
07-31-2005, 10:03 AM
Just tested, works fine for me on RC 1
Boofo
07-31-2005, 10:31 AM
Any way to get it to work with editpost?
Andreas
07-31-2005, 10:32 AM
It works everywhere, just like replacement Variables.
Boofo
07-31-2005, 10:36 AM
It works everywhere, just like replacement Variables.
LOL You're right. I guess I didn't test editing a post. Great job, sir! ;)
Blows the one I did for vb3 all to you-know-what. One less I have to mess with. ;)
Boofo
08-01-2005, 12:06 PM
But it doesn't work in the archive. Any way to fix that?
Andreas
08-01-2005, 12:14 PM
Not without a File edit ...
Boofo
08-01-2005, 12:54 PM
And what would that be?
Andreas
08-01-2005, 12:58 PM
Easiest way:
At start of index.php put
ob_start();
At the end put
$output = ob_get_contents();
ob_end_clean();
echo str_replace('[username'], $vbulletin->userinfo['username'], $output);
Boofo
08-01-2005, 01:02 PM
Then that should cover it for the whole site, right?
Andreas
08-01-2005, 01:04 PM
For the whole archive, yes.
Boofo
08-01-2005, 01:09 PM
For some reason, that didn't work. :(
Andreas
08-01-2005, 01:10 PM
Hmm .. it should.
You edited the correct index.php (rember there are three of them), right?
Boofo
08-01-2005, 01:13 PM
The archive index.php, right?
Andreas
08-01-2005, 01:16 PM
Yes. Just tested, does work for me.
Boofo
08-01-2005, 01:24 PM
Ok, where exactly did you put it? I did it right after the opening php tag and right before the ending one.
Andreas
08-01-2005, 01:26 PM
Above
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
And above the closing Tag.
Boofo
08-01-2005, 01:31 PM
Damn! It still shows the actual [you] tag and not the username in the archive post. I did the edit exactly as you said, too. :(
Boofo
08-01-2005, 01:34 PM
Scratch that last post. It works. ;)
I'm too embarrassed to admit what I did so that will be MY secret (like the thread creationtime?) ;)
Boofo
08-01-2005, 01:40 PM
This line is giving me fits:
echo str_replace('[username'], $vbulletin->userinfo['username'], $output);
I am getting an error with it.
EDIT:
I changed it to this and I no longer get any errors.
echo str_replace('[username]', $vbulletin->userinfo['username'], $output);
But it's just not working. I can still see the tag in the past in the archive. :(
Andreas
08-01-2005, 02:11 PM
Yeah, that was a typo :)
Hmm, don't know why it isn't working for you - works for me.
Boofo
08-01-2005, 02:14 PM
Is there another way to do it then? It's got me stumped.
Andreas
08-01-2005, 02:18 PM
Think so. But IMHO the way I posted is the easiest.
PM me FTP details and i'll take a look.
Boofo
08-02-2005, 12:22 PM
I found the problem. I was using [username] in the first variable where I should have been using [you]. DUH on me! ;)
It works like a charm now. ;)
Thank you, sir. ;)
Brandon Sheley
08-17-2005, 06:48 AM
hm, i can't seem to get it. i just put the php code in the arcive.index and it shoudl show the userid when [username] is typed ? in the title and in the body ? cuz it doesn't show for me. do i have to activate something ?
havefun
10-14-2005, 01:02 PM
working fine, THX kirby :)
Extreme John
10-25-2005, 04:34 AM
Wow first time working with code like this and it was a charm, you rock Andreas thank you, I have been looking for this forever for both versions.
Quick question; how come when you use quick edit and enter [username] it is displayed as "[username]" not "KerbyDE"?
Thanks,
Mat
Very nice. Could be very useful in a lot of situations.
TheMusicMan
02-05-2006, 07:35 PM
When I edit the post, then save, it shows [username] and not themusicman or whatever???
Borgs8472
02-05-2006, 09:20 PM
^ ^
yeah.
If you 'go advanced' it gets fixed, however it's no longer dynamic...
TheMusicMan
02-16-2006, 02:12 PM
^ Thanks.
Is there any way this can be enhanced so as only Admins/Smods/Mods can use it? Is there a conditional I can wrap around the php code to effect this?
Cheers.
zagman76
02-24-2006, 06:51 PM
is there a way that this can be limited to specific forums/sub-forums? if so, how?
Thanks!!!
Smiry Kin's
02-27-2006, 04:42 AM
Hookname: global_complete
$output = str_replace('[username]', $vbulletin->userinfo['username'], $output);
Please note that this replace takes place EVERYWHERE.
sorry but where do i add that?...
Phrost
03-05-2006, 06:17 PM
Very strange. It works in titles, but not in posts.
Smiry, go to the Plugin system, chose Vbulletin General -> global_complete from the pulldown menu.
Anyway, anyone know why it wouldn't work in a post?
Is this updated for 3.5.4? It tells me my message is too short on any post when I try to create a thread after installing this hook.
Argyle
04-01-2006, 04:20 AM
The following worked for me for post body for all forums, it doesn't cover thread title or anything else. The first post replaced the username code with my own name as I was posting it.
postbit_display_complete
$post[message] = str_replace('[username]', $vbulletin->userinfo['username'], $post[message]);
Borgs8472
04-26-2006, 08:56 PM
I was annoyed to find when this gets mixed with the auto url thingy, it stops working.
I wanted to post a link to:
http:/[username].justgotowned.com/
However the hyperlink doesn't change to the username, but the name of it does :(
I was annoyed to find when this gets mixed with the auto url thingy, it stops working.
I wanted to post a link to:
http:/[username].justgotowned.com/
However the hyperlink doesn't change to the username, but the name of it does :(
Well, the auto url feature consists of two separate sides: the textual name and the link itself. While the text gets adapted when you log in, the actual link is set to whatever you type right away. I'm afraid that's the way it's naturally supposed to work.
Evil Chris
06-29-2006, 01:22 PM
works nice... thanks.
sillystuie
08-25-2006, 02:41 PM
AWESOME!!! ive been looking for something like this for my "happy (insert holiday) user" threads :) :) :) :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.