MyBB - Add advanced forum signature

Extend MyBB forum with 3 code snippets

MyBB is a robust open source bulletin board or forum software. One of the reasons of its popularity is that you can easily modify it with a working knowledge of HTML and PHP. Here are three simple MyBB modifications to make your forum more interesting and safe.

Advanced MyBB Signature

MyBB - Add advanced forum signature

You can add social media links of the forum poster in the signature using the following code by Omid KatimZade. You will have to edit the “postbit_signature” file of the MyBB theme that you are using. Go to Admin Control Panel (ACP)-> Templates & Style -> Themes -> [Your Theme] -> postbit -> postbit_signature. Replace the existing code with the below one.

<fieldset class="fieldset"><legend><b><strong><fieldset class="fieldset"><font color="#C71585">Signature
<strong><span class="largetext"><a href="#" id="profilelink_{$post['pid']}">{$post['username_formatted']}</span></strong></a>
<div id="profilelink_{$post['pid']}_popup" class="popup_menu" style="display: none;">
<div class="popup_item_container">
<a href="{$mybb->settings['bburl']}/member.php?action=profile&uid={$post['uid']}" class="popup_item">View User Profile</a>
</div>
<div class="popup_item_container">
<a href="{$mybb->settings['bburl']}/search.php?action=finduser&uid={$post['uid']}" class="popup_item">View  user Posts</a>
</div>
<div class="popup_item_container">
<a href="{$mybb->settings['bburl']}/search.php?action=finduserthreads&uid={$post['uid']}" class="popup_item">View  user Threads</a>
</div>
<div class="popup_item_container">
<a href="{$post['website']}" target="_blank" " class="popup_item">View  user Website</a>
</div>
<div class="popup_item_container">
<a href="{$mybb->settings['bburl']}/private.php?action=send&uid={$post['uid']}" class="popup_item">Send a private message to user</a>
</div>
<div class="popup_item_container">
<a href="{$mybb->settings['bburl']}/member.php?action=emailuser&uid={$post['uid']}" class="popup_item">Send mail to user</a>
</div>
</div><br />
<script language="javascript" type="text/javascript">
new PopupMenu("profilelink_{$post['pid']}");
</script></font></strong></b><br /><a href="misc.php?action=imcenter&imtype=yahoo&uid=$post[uid]" onclick="popupWin('misc.php?action=imcenter&imtype=yahoo&uid=$post[uid]', 'imcenter', 450, 300);">
<img src="http://up.iran-talk.ir/uploads/13317439651.png" alt="Send a message to the user through Yahoo" width="17" height="17" border="0" title="اSend a message to the user through Yahoo"></a><a href="misc.php?action=imcenter&imtype=msn&uid=$post[uid]" onclick="popupWin('misc.php?action=imcenter&imtype=msn&uid=$post[uid]', 'imcenter', 450, 300);">
<img title="Send a message to the user through MSN" src="http://up.iran-talk.ir/uploads/13317446821.png" alt="اSend a message to the user through MSN" border="0"></a><a href="misc.php?action=imcenter&imtype=aim&uid=$post[uid]" onclick="popupWin('misc.php?action=imcenter&imtype=aim&uid=$post[uid]', 'imcenter', 450, 300);">
<img src="http://up.iran-talk.ir/uploads/13317446822.png" alt="اSend a message to the user through AIM" width="17" height="17" border="0" title="Send a message to the user through AIM"><a href="misc.php?action=imcenter&imtype=icq&uid=$post[uid]" onclick="popupWin('misc.php?action=imcenter&imtype=icq&uid=$post[uid]', 'imcenter', 450, 300);">
<img src="http://up.iran-talk.ir/uploads/13317462711.gif" alt="Send a message to the user through ICQ" width="17" height="17" border="0" title="Send a message to the user through ICQ"></a></fieldset>{$post['signature']}</fieldset></legend> 

No-Follow Forum User Links

By default, MyBB allows all users website filed under “www” as “do-follow”, which is not very great for SEO. You can edit the “postbit_www” file of your theme to make all links “nofollow” and prevent passing of authority and link juice. Go to AdminCP -> Template>Modify/Delete and select your template and click on “Expand”. Locate the ‘Post Bit Templates’ and click on “Expand” from the right side. Now, locate ‘postbit_www’ and find the following code:

<a href="{$post['website']}" target="_blank">

Replace the above code with the following to add the “nofollow” instruction for search engine bots.

<a href="{$post['website']}" target="_blank" rel="nofollow">

Goes without saying, save the template file. 🙂

External Link Redirection Page

Do you need to alert your MyBB forum users whenever they click on an external link redirecting them to an unaffiliated website.

First, create an HTML file and name it “redirect.html” file in the root directory of your MyBB forum.

<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />        
        <style>
            #panel{
                width: 500px;
                border: 1px solid;
                border-color:#999999;
                margin:50px auto;
                padding: 8px;
                font: 12px tahoma;
                text-align:center;
                background-color:#fcfbf7;
            }
        </style>
    </head>
    <body>
        <script type="text/javascript">
            var link=decodeURIComponent(location.search.substr(6));    
            second = 10; //Wait time in seconds
            function AutoRedirect(){
                document.getElementById('time').innerHTML=second;
                if(second==0){
                    location.href=link;
                }
                second--;
            }
        </script>
        <div id="panel">
            <p>You clicked on a link that not belong to our site.        
            </p>
            <script type="text/javascript">
                document.write("<a href='"+link+"'>"+link+"</a>")
            </script>
            <p>Auto redirect in<span id="time"></span> second(s).</p>
        </div>
        <script type="text/javascript">
            AutoRedirect(second);
            setInterval("AutoRedirect(second)",1000);
        </script>
    </body>
</html>

Now, add the following to the footer template file of your theme. Don’t forget to change “yourwebsite.com” with the actual URL of yuour site. You can add more site URLs to the safe sites list.

<script type="text/javascript" >
    $$('div.post_body a').each(function(s){
        link=s+'';
        if(!link.include('yoursite.com') && !link.include('javascript') && !link.include('mybb.com')){
        s.href="redirect.html?link="+encodeURIComponent(link);
        s.target="_blank";
        }
    });
</script>

[]