MyBB Community Forums

Full Version: Approve / Deny Apply Buttons
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I know that most websites do not utilize this, but I have seen a few postings, and wanted to share some custom code I put into my website. It took me quite a bit of time and trial and error to get this to work properly.

My site has multiple groups across several games, and we use applications to screen new members that come into our community. This is common among online gaming. What I have done is created two buttons that are displayed on these application postings and can quickly put applicants into proper member groups.

[Image: ApproveDeny.jpg]



Getting Started
You will need to have the PHP and Template Conditionals plugin for this to work. I use Nickman's Form Manager for our application forms, but that is an optional plugin, as there are no edits done to that plugin.

Required Plugins:
PHP and Template Conditionals

Optional Plugins:
Form Manager

You will also need to make sure that you are already logged into the Admin CP prior to clicking the buttons. Should you not be logged in prior to it, when you click the button, it will prompt you to log into the Admin CP, and stop the button before it can process through the code.

Should you want to give others this access, you will need to make sure that they have admin access also. What I have done is limited those that can use these buttons to only being allowed to edit users.



The Edits
The template edits will need to be done in postbit and postbit_classic. Both templates will get the same edits. You will want to make your edits after the line below:

{$post['message']}

Depending on where you want the buttons, you could place it before the message, but it is recommended to be after.



Example Code
Below is an example of the code for one of our sections. There are 2 edits that would need to change, if you would want to utilize this for other forum sections or member groups.

<if $usergroup['gid'] == 2 and $forum['fid'] == 16 and $post['pid'] == $thread['firstpost'] and $thread['closed'] == 0 then>
<!--- Elder Scrolls Online Approve --->
<div class="appbutton">
<if $mybb->user['usergroup'] == 4 or $mybb->user['usergroup'] == 43 then>
<div class="float_left"><form action="admin/index.php?module=user-users&amp;action=edit&amp;uid={$post['uid']}" method="post" enctype="multipart/form-data" target="_blank">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="hidden" name="username" value="{$post['username']}" />
<input type="hidden" name="email" value="{$post['email']}" />
<input type="hidden" name="displaygroup" value="0" />
<input type="hidden" name="postcount" value="{$post['postnum']}" />
<input type="hidden" name="usergroup" value="16" />
<input type="hidden" name="invisible" value="0">
<input type="hidden" checked="checked" value="1" name="allownotices">
<input type="hidden" checked="checked" value="1" name="receivepms">
<input type="hidden" checked="checked" value="1" name="pmnotice">
<input type="hidden" checked="checked" value="1" name="showsigs">
<input type="hidden" checked="checked" value="1" name="showavatars">
<input type="hidden" checked="checked" value="1" name="showquickreply">
<input type="submit" value="Approve" class="approveapp" />
</form></div>

<div class="float_right">
<form action="{$mybb->settings['bburl']}/moderation.php" method="post">
<input type="hidden" name="tid" value="{$thread['tid']}" />
<input type="hidden" name="action" value="openclosethread" />
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="submit" value="Denied" class="declineapp" />
</form></div>
</if>



Understanding the Code
I'm going to break down portions of the code and explain into more detail how they work and why.

<if $usergroup['gid'] == 2 and $forum['fid'] == 16 and $post['pid'] == $thread['firstpost'] and $thread['closed'] == 0 then>

This runs through multiple checks to determine if the Approve / Deny button should be displayed. It checks that the person posting is in the usergroup 2, the defaulted registered group. Then it checks that the post is in the Forum ID of 16, in the case of my website, Elder Scrolls Online Applications section. This will make sure that the buttons do not get placed onto threads of other forum sections.

Then it checks that it is the first posting, this way that the Approve / Deny button does not get placed onto other posts if you are having a discussion with the applicant. Lastly, it checks that the thread is not closed. Presumably, if a thread is locked, the applicant has been denied or approved, and the thread was locked after approval.


<if $mybb->user['usergroup'] == 4 or $mybb->user['usergroup'] == 43 then>

This one is simple enough, it sets who will see the button. In this case, myself as admin in group 4, and our Elder Scrolls Leader in group 43.


<form action="admin/index.php?module=user-users&amp;action=edit&amp;uid={$post['uid']}" method="post" enctype="multipart/form-data" target="_blank">

This creates the link for the button, that will edit the user of the posting. Since the code checks that this is only displayed for those in group 2 and the first post of a thread, it will edit the applicant.


<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="hidden" name="username" value="{$post['username']}" />
<input type="hidden" name="email" value="{$post['email']}" />
<input type="hidden" name="displaygroup" value="0" />
<input type="hidden" name="postcount" value="{$post['postnum']}" />
<input type="hidden" name="usergroup" value="16" />
<input type="hidden" name="invisible" value="0">
<input type="hidden" checked="checked" value="1" name="allownotices">
<input type="hidden" checked="checked" value="1" name="receivepms">
<input type="hidden" checked="checked" value="1" name="pmnotice">
<input type="hidden" checked="checked" value="1" name="showsigs">
<input type="hidden" checked="checked" value="1" name="showavatars">
<input type="hidden" checked="checked" value="1" name="showquickreply">
<input type="submit" value="Approve" class="approveapp" />

This portion of the code was what caused most of the issues. When editing an user through this button, if certain information is in there, it wants to fill in blanks for information. For example, the second line of this portion prompts for the email address. An error that I received while creating this was that it wanted to edit the user, but said a valid email was needed. What was happening was that when I pressed the button, it put in a blank value for the email.

Another issue was that certain boxes were being unchecked, that are typically checked. This is why the lower portion sets certain values to "1", to be checked. These would cause avatars, signatures, and quick reply boxes to be hidden, as example. As a result, the overall theme, and layout of forum pages would not appear correct, and would look like a mess without having those set.

The important portion of this code is the 6th line. In the case of this code, it is placing the user into the member group 16. In the case of my site, Elder Scrolls Online member group.

<form action="{$mybb->settings['bburl']}/moderation.php" method="post">
<input type="hidden" name="tid" value="{$thread['tid']}" />
<input type="hidden" name="action" value="openclosethread" />
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="submit" value="Denied" class="declineapp" />
</form>

This final portion of the code is for the denied button. This will automatically lock the thread. Going back to the first line, once denied and the post is locked, the Approve / Deny buttons will not be visible.
when i use this i get this:

 Parse error: syntax error, unexpected ';' in /inc/functions_post.php(799) : eval()'d code on line 74

copied the same code your using just changed usergroup n gid.

nevermind in 1.8 had to change somethings.

<if $mybb->user['usergroup'] == 4 and $forum['fid'] == 4 and $post['pid'] == $thread['firstpost'] and $thread['closed'] == 0 then>


<!--- Elder Scrolls Online Approve --->
<div class="appbutton">

<div class="float_left"><form action="admin/index.php?module=user-users&amp;action=edit&amp;uid={$post['uid']}" method="post" enctype="multipart/form-data" target="_blank">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="hidden" name="username" value="{$post['username']}" />
<input type="hidden" name="email" value="{$post['email']}" />
<input type="hidden" name="displaygroup" value="2" />
<input type="hidden" name="postcount" value="{$post['postnum']}" />
<input type="hidden" name="usergroup" value="2" />
<input type="hidden" name="invisible" value="0">
<input type="hidden" checked="checked" value="1" name="allownotices">
<input type="hidden" checked="checked" value="1" name="receivepms">
<input type="hidden" checked="checked" value="1" name="pmnotice">
<input type="hidden" checked="checked" value="1" name="showsigs">
<input type="hidden" checked="checked" value="1" name="showavatars">
<input type="hidden" checked="checked" value="1" name="showquickreply">
<input type="submit" value="Approve" class="approveapp" />
</form></div>

<div class="float_right">
<form action="{$mybb->settings['bburl']}/moderation.php" method="post">
<input type="hidden" name="tid" value="{$thread['tid']}" />
<input type="hidden" name="action" value="openclosethread" />
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="submit" value="Denied" class="declineapp" />
</form></div>
  </if>
Could you post the changes made for 1.8? I'm using 1.6 on the forum with this modification, but would like to have it for those using 1.8.
this is what i got to work on 1.8 the other one didn't want to work to well without giving parse error.

<if $mybb->user['usergroup'] == 4 and $forum['fid'] == 4 and $post['pid'] == $thread['firstpost'] and $thread['closed'] == 0 then>


<!--- Elder Scrolls Online Approve --->
<div class="appbutton">

<div class="float_left"><form action="admin/index.php?module=user-users&amp;action=edit&amp;uid={$post['uid']}" method="post" enctype="multipart/form-data" target="_blank">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="hidden" name="username" value="{$post['username']}" />
<input type="hidden" name="email" value="{$post['email']}" />
<input type="hidden" name="displaygroup" value="2" />
<input type="hidden" name="postcount" value="{$post['postnum']}" />
<input type="hidden" name="usergroup" value="2" />
<input type="hidden" name="invisible" value="0">
<input type="hidden" checked="checked" value="1" name="allownotices">
<input type="hidden" checked="checked" value="1" name="receivepms">
<input type="hidden" checked="checked" value="1" name="pmnotice">
<input type="hidden" checked="checked" value="1" name="showsigs">
<input type="hidden" checked="checked" value="1" name="showavatars">
<input type="hidden" checked="checked" value="1" name="showquickreply">
<input type="submit" value="Approve" class="approveapp" />
</form></div>

<div class="float_right">
<form action="{$mybb->settings['bburl']}/moderation.php" method="post">
<input type="hidden" name="tid" value="{$thread['tid']}" />
<input type="hidden" name="action" value="openclosethread" />
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="submit" value="Denied" class="declineapp" />
</form></div>
  </if>
1.8 also added a couple other settings. I would suggest also adding the code below

<input type="hidden" checked="checked" value="1" name="showimages">
<input type="hidden" checked="checked" value="1" name="showvideos">
Is there a way we can make it so when the deny button is pressed, it renames the thread subject to DENIED (Thread name here)?
This sounds useful. Could someone make it into a plugin?
Being able to insert buttons for custom moderation tools in threads, posts, or both could be useful in the core.
I don't think DENY and APPROVE could apply to threads, which in some sense already exist. They could only be useful to posts which need to be approved but have not yet been approved.

Quote:Being able to insert buttons for custom moderation tools in threads, posts, or both could be useful in the core.
I agree. They need to be styled like other buttons.
Does this still work?