MyBB Community Forums

Full Version: Hide Reputation Button from Own Posts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:

<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:

<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:

<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!!! Big Grin

Snap:
[Image: 5jJs09B.png]

Happy coding.
This effone has been posting the same tutorial all over WWW.
(2013-03-24, 05:15 PM)ElectricShock Wrote: [ -> ]This effone has been posting the same tutorial all over WWW.

That is the way to protect your authored material being published with some other's name :p
Atleast someone popup and point to any of the original sources.