Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 New Thread/Reply Button Depends On Permission
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #1
New Thread/Reply Button Depends On Permission
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


(This post was last modified: 12-07-2010 05:44 AM by RateU.)
12-07-2010 05:16 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
New Thread/Reply Button Depends On Permission - RateU - 12-07-2010 05:16 AM

 Standard Tools
Forum Jump: