XF 2.1 How to Remove @username Mention Link in Post?

jgaulard

Active member
Hi,

I'd like to remove the anchor text that surrounds the "@Username" mentions that a member can place inside a post. Basically, I'd like to kill the link, but leave the @Username text. I am currently searching through the many templates in hopes to find this bit of code I can edit out, but I can't seem to locate it.

Would anyone happen to know which template it's contained in?

Thanks.

Jay
 
This is mention BBcode, but it is formatted in file Formatter.php (src/XF/Str/Formatter.php):

PHP:
    public function linkStructuredTextMentions($string)
    {
        $string = $this->moveHtmlToPlaceholders($string, $restorePlaceholders);

        $string = preg_replace_callback(
            '#(?<=^|\s|[\](,/\'"]|--|@)@\[(\d+):(\'|"|&quot;|)(.*)\\2\]#iU',
            function(array $match)
            {
                $userId = intval($match[1]);
                $username = $this->removeHtmlPlaceholders($match[3]);
                $username = htmlspecialchars($username, ENT_QUOTES, 'utf-8', false);

                $link = \XF::app()->router('public')->buildLink('full:members', ['user_id' => $userId]);

                return sprintf('<a href="%s" class="username" data-user-id="%d" data-username="%s" data-xf-init="member-tooltip">%s</a>',
                    htmlspecialchars($link), $userId, $username, $username
                );
            },
            $string
        );

        $string = $restorePlaceholders($string);

        return $string;
    }

You need to edit this file to your liking.
 
Back
Top Bottom