MyBB Group
jQuery Add Approve / Unapprove button to each post - Printable Version

+- MyBB Group (https://mybb.group)
+-- Forum: Beside You (https://mybb.group/Forum-Beside-You)
+--- Forum: Guidebook (https://mybb.group/Forum-Guidebook)
+--- Thread: jQuery Add Approve / Unapprove button to each post (/Thread-jQuery-Add-Approve-Unapprove-button-to-each-post)



Add Approve / Unapprove button to each post - effone - 07-05-2020

This will add Approve / Unapprove button to each post.
This is a very basic and nominal mod for those new friends exploring MyBB. This can be further extended and enhanced as per your need.

Open template showthread_inlinemoderation, find the first line:
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/inline_moderation.js?ver=1818"></script>

ADD the following piece of script just after that:
<script type="text/javascript">
var apbt = "<a href='#' data-act='{act}' class='postbit_approve'><span>{txt}</span></a>", // Button template
    btxt = ["Approve", "Unapprove"]; // Button texts
lang.noapprove = "Deleted posts can't be approved / unapproved." // Error message for deleted posts

$(".post_management_buttons").each(function () {
    var act = $(this).parents(".post").hasClass("unapproved_post") ? 0 : 1;
    $(this).append(apbt.replace("{act}", act).replace("{txt}", btxt[act]))
}), $(function () {
    $(".postbit_approve").on("click", function () {
        return $(this).parents(".post").hasClass("deleted_post") ? $.jGrowl(lang.noapprove, {theme: "jgrowl_error"}) : ($("#" + $(this).parents(".post").attr("id").replace("post", "inlinemod")).trigger("click"), $("#inlinemoderation_options_selector").val("multi" + (+$(this).data("act") ? "un" : "") + "approveposts").change(), $("#inlinemoderation_options").trigger("submit")), !1
    })
});
</script>

Change the strings in first three lines, if you are using different language.

Note: 
  • There are several ways to do this but this script uses MyBB's inbuilt tools only.
  • This mod is just for fun and with js only. js disabled sites will not work.
  • To obtain a proper full functionality you need to have a plugin.

Result:

[Image: screen793366412e3a6466.gif]