Hide Reputation Button from Own Posts
#1
We can see in thread view - all the posts have a button to give reputation to the user for the post. However; if you click the reputation button in your own post - it comes out as an error message stating:

Quote:You cannot add to your own reputation.

I felt this is somehow unwanted. So, here I'm to show you how we can hide reputation button from own posts.

We are going to hide the button using jQuery. So, at first include jQuery library to your board using the well-known method, if it is not already.

Next, open the template:
ACP > Templates & Styles > Templates > {$theme_name} Templates > Postbit Templates > postbit_rep_button

Find the code of the Button image (works fine with css buttons too) and bind it in an ID.

<span id="selfrep{$post['pid']}"><a href=" .... ....</a></span>

For example:

The default theme's code:

PHP Code:
<a href="javascript:MyBB.reputation({$post['uid']},{$post['pid']});"><img src="{$theme['imglangdir']}/postbit_reputation.gif" alt="{$lang->postbit_reputation_add}title="{$lang->postbit_reputation_add}/></a

Change it to:

PHP Code:
<span id="selfrep{$post['pid']}"><a href="javascript:MyBB.reputation({$post['uid']},{$post['pid']});"><img src="{$theme['imglangdir']}/postbit_reputation.gif" alt="{$lang->postbit_reputation_add}title="{$lang->postbit_reputation_add}/></a></span

Now the decision making and hiding part using jQuery. Add at the very end of the same template:

PHP Code:
<script type="text/javascript">
jQuery.noConflict(); 
jQuery(function() {
if({
$post['uid']} == {$mybb->user['uid']}) {
jQuery('#selfrep{$post['pid']}').hide();
 }
});
</
script

Save the template and you are done!!! Grin

Snap:
[Image: 5jJs09B.png]

Happy coding.
Reply
#2
Good idea, thanks for sharing. Could easily be done using pure JavaScript or even Prototype too.
Reply
#3
Should be default in MyBB IMO. Good tutorial, definitely add professionalism to a forum.
Reply