1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Change profile URL for user @ tags

Discussion in 'XenForo Development Discussions' started by AUSFIFA, Aug 1, 2015.

  1. AUSFIFA

    AUSFIFA Member

    I'm running a Xenforo forum that is inbuilt into my own PHP website using my own user log in (with a bridge for XF login) and profile pages: AUSFIFA | Forums

    I've managed to change all username links so that they point to my own profile pages instead of Xenforo's.

    So rather than "forums/index.php?members/kani.1/", it would point to "profile.php?user=Kani".

    The only problem is I can't figure out how to change the URL for when you tag a user. So if you type @AUSFIFA, I want it to link my own profile page instead of Xenforo's.

    I've looked everywhere in the code but can't seem to find what I need to be changing.

    Thanks.
     
  2. Liam W

    Liam W Well-Known Member

    It just uses the standard link system, so edit/extend the member route class.

    Liam
     
  3. AUSFIFA

    AUSFIFA Member

    I don't really do much work on Xenforo so I'm not sure where I'm meant to be looking. Can you elaborate please?

    Where can I find the member route class?

    Thanks for the swift response!
     
  4. Liam W

    Liam W Well-Known Member

    library/XenForo/Route/Prefix/Members.php

    Edit the buildLink method.

    Liam
     
  5. AUSFIFA

    AUSFIFA Member

    Yep ended up finding it, although one small issue. It prefaces anything the buildLink method returns with "ausfifa.com/forums/index.php?members"? I need to access the site's root directory for profile.php.
     
    Last edited: Aug 1, 2015
  6. AUSFIFA

    AUSFIFA Member

    The buildLink method inside the member route class only gives me the end of the string which is just the ID of the user to serve their profile.

    I can't seem to find the method which deals with the entire URL.
     
    Last edited: Aug 1, 2015
  7. katsulynx

    katsulynx Well-Known Member

    You could essentially just replace Line 32
    PHP:
    return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix$action$extension$data'user_id''username');
    with
    PHP:
    return 'members.php?='.$data['user_id'];
    Even though it's not recommended to edit XenForo-Files directly.
     
  8. AUSFIFA

    AUSFIFA Member

    Yeah I did exactly that, the issue is this method only returns the very end of the URL rather than the entire thing. No matter what you return in the method, it always begins with "ausfifa.com/forums/index.php?members". I need to modify the entire URL since my profile page is on the root level of the website: ausfifa.com/profile.php?user=Kani
     
  9. katsulynx

    katsulynx Well-Known Member

    My example is definitly not routing you to 'index.php?members' but 'members.php'.
     
  10. AUSFIFA

    AUSFIFA Member

    Nope, it returns "www.ausfifa.com/forums/index.php?members.php?=1" as the link.

    No matter what you return from the method, there's always the forums/index.php? in front of it.
     
  11. AUSFIFA

    AUSFIFA Member

    Can anyone please help me with this issue?
     
  12. AUSFIFA

    AUSFIFA Member

    I still cannot find the solution to this. Can anyone help?
     
  13. Jeremy

    Jeremy XenForo Moderator Staff Member

    When tagging a user it is actually converted into a BBCode. So when I tag you, @AUSFIFA, it really turns into [USER=71955]AUSFIFA[/USER]. You can exploit this for yourself by extending the formatter that returns BBCode.

    This guide will help you along the way for proper implementation:
    https://xenforo.com/community/threa...b-code-in-xenforo-a-comprehensive-guide.6320/

    However, you want to overwrite renderTagUser or overwrite the tag definition. If you want, something like this should work:

    PHP:
    <?php

    class MyAddon_BbCode_Formatter_BbCode_Base extends XFCP_MyAddon_BbCode_Formatter_BbCode_Base
    {
        public function 
    getTags()
        {
            
    $tags parent::getTags();
            
    $tags['user'] = array(
                
    'hasOption' => true,
                
    'stopSmilies' => true,
                
    'callback' => array($this'myRenderTagUser')
            );
            
            return 
    $tags;
        }
        
        public function 
    myRenderTagUser(array $tag, array $rendererStates)
        {
            
    $content $this->renderSubTree($tag['children'], $rendererStates);
            if (
    $content === '')
            {
                return 
    '';
            }

            
    $userId intval($tag['option']);
            if (!
    $userId)
            {
                return 
    $content;
            }

            
    $username $this->stringifyTree($tag['children']);

            return 
    $this->_wrapInHtml('<a href="http://yoururl.com/members.php?u=' htmlspecialchars($username) . '" class="username" data-user="' $userId ', ' htmlspecialchars($username) . '">''</a>'$content);
        }
    }
     
    AUSFIFA likes this.
  14. AUSFIFA

    AUSFIFA Member

    Works great but it's including the @ tag in the URL for me? So instead of:
    http://www.ausfifa.com/profile.php?user=Member

    It comes up as:
    http://www.ausfifa.com/profile.php?user=@Member
     
  15. Jeremy

    Jeremy XenForo Moderator Staff Member

    User str_replace to strip it out from $username.
     
  16. AUSFIFA

    AUSFIFA Member

    Yeah ended up doing that, was just wondering if there was a way to get it without having to do that.

    Thanks for your help bud, really appreciate it!
     
  17. Jeremy

    Jeremy XenForo Moderator Staff Member

    You can disable the keeping of the @ in the options if you prefer the display without it, but that doesn't work retroactively.
     
  18. AUSFIFA

    AUSFIFA Member

    @Jeremy, apologies but I have no idea where to ask this, is there any way I can change my Xenforo forums username?
     
  19. Brogan

    Brogan XenForo Moderator Staff Member

    Start a conversation with me, or any of the other moderators, requesting the new name.
     

Share This Page