MyBB Hacks

Full Version: New Thread/Reply Button Depends On Permission
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Required: Template Conditionals or PHP in Templates / Complex Templates plugin.

This will hide the New Thread button automatically when a user doesn't have permission to create a new thread in a forum.

forumdisplay_newthread:

HTML Code
<if $fpermissions['canpostthreads'] == 1 then>
<a href="newthread.php?fid={$fid}"><img src="{$theme['imglangdir']}/newthread.gif" alt="{$lang->post_thread}" title="{$lang->post_thread}" /></a>
</if>


This will hide the New Reply button automatically when a user doesn't have permission to post a new reply in a thread.

showthread_newreply:

HTML Code
<if $forumpermissions['canpostreplys'] == 1 then>
<a href="newreply.php?tid={$tid}"><img src="{$theme['imglangdir']}/newreply.gif" alt="{$lang->post_reply_img}" title="{$lang->post_reply_img}" /></a>&nbsp;
</if>


The same conditional if we want to hide the Reply button in postbit:
postbit_quote template:

HTML Code
<if $forumpermissions['canpostreplys'] == 1 then>
<a href="newreply.php?tid={$tid}&amp;pid={$post['pid']}"><img src="{$theme['imglangdir']}/postbit_quote.gif" alt="{$lang->postbit_quote}" title="{$lang->postbit_quote}" /></a>
</if>


We can use a <else> condition for users who don't have permission.
For example, we can use a button to link to our registration page, and use a different image:

HTML Code
<if $fpermissions['canpostthreads'] == 1 then>
<a href="newthread.php?fid={$fid}"><img src="{$theme['imglangdir']}/newthread.gif" alt="{$lang->post_thread}" title="{$lang->post_thread}" /></a>
<else>
<a href="{$mybb->settings['bburl']}/member.php?action=register"><img src="{$theme['imglangdir']}/register.gif" alt="Register" title="Only member can post a thread in this forum. Please register first" /></a>
</if>


Maybe it is useless, but, I just want to share it Biggrin
And please tell me if I had made a mistake with the code Biggrin

Hey RateU,
your post inspired me for the attached plugin.
Nice tips and work Smile
Thank you RateU. Great info.
Thanks RateU.
thanks rateu
Really cool, thanks RateU.
Thanks Biggrin
And thanks to TriTop for sharing Smile
lol. i'm noob in making plugins. otherwise i would have shared some cool plugins.
The credit belongs to you RateU. You be bubbling over with ideas. Glad to give back something to this great community. Smile
Reference URL's