MyBB Community Forums

Full Version: Twitter-style [@name]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
I was going to do this for my website. But since there is already a plug-in. I won't need to. Thanks Big Grin
The downlod don't work Confused
The download link do not work!!!
fix it plz
bump, link don't work
(2010-06-05, 02:31 PM)alv4 Wrote: [ -> ]The download don't work...

(2010-06-08, 07:34 PM)Silver~ Wrote: [ -> ]The download link do not work!!!
fix it plz

(2010-06-09, 03:33 AM)Glas Wrote: [ -> ]bump, link don't work


A working version is posted below w/ no line break issue:

Here you go, this version gives credit to both Lee and Aquilez, for his code posted here:
http://community.mybb.com/thread-66308-p...#pid479191

file-name = /inc/plugins/twitter.php
<?php

if (!defined("IN_MYBB")) {
die("Direct initialization of this plugin disabled.<br /><br />Please make sure IN_MYBB is defined.");
}

//  Added "function twitter_info()" to Aquilez's code:
function twitter_info()
{
    return array(
        "name"          => "Twitter-like @name",
        "description"   => "@name will return link to names profile.",
        "website"       => "http://mods.mybboard.net/",
        "author"        => "Lee Merriman w/ Aquilez",
        "authorsite"    => "http://community.mybb.com/thread-66308-post-479191.html#pid479191",
        "version"       => "1.46"
    );
}

$plugins->add_hook("parse_message", "twitter");
$plugins->add_hook("member_profile_start", "twitter_username_redirect");

function twitter(&$message2)
{
    global $mybb, $db;

    $message2 = preg_replace('/(^|[^a-z0-9_])@([a-z0-9_]+)/i', ' @<a href="member.php?action=profile&username=$2">$2</a>', $message2);

    return $message2;
}

function twitter_username_redirect()
{
    global $mybb, $db;
    
    if(!empty($mybb->input['username']))
    {
        $q = $db->simple_select('users', 'uid', 'username = "' . $mybb->input['username'] . '"');
        
        $result = $db->fetch_array($q);
        
        $mybb->input['action'] = 'profile';
        
        if(is_array($result))
        {
            //header('Location: member.php?action=profile&uid=' . $result['uid']);
            $mybb->input['uid'] = $result['uid'];
        }
        else
        {
            // User not found
            //header('Location: member.php?action=profile&uid=0');
            $mybb->input['uid'] = 0;
        }
    }
} 

?>

Optional:
Change this line to...
    $message2 = preg_replace('/(^|[^a-z0-9_])@([a-z0-9_]+)/i', ' <a href="member.php?action=profile&username=$2">@$2</a>', $message2);

...then the @ is part of the linked text, instead of 'sitting out in front'.


Note:
> Use @user, not [@user]
Tested on MyBB1.4, should work on 1.6, will test later.
  • Anyone have time to post a quick test result from MyBB1.6?



Working fine on 1.6.

I wish this were expanded in to a notification system so that when you type @username they get a notification similar to the new PM notification.
Download won't work. :/
That would be due to the site being deleted from what I can tell.
PS: Hi Cody Toungue
Haha, hey Austin.

I guess I'll just check later.
Is there any way to send a user a PM when they're tagged in a post?
Pages: 1 2 3 4