Making WordPress.org

Ticket #4904: 4904.diff

File 4904.diff, 1.5 KB (added by valentinbora, 5 years ago)

Allow moderators to reply to closed topics through the bbp_current_user_can_access_create_reply_form filter

  • wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php

    diff --git wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php
    index eea74abe1..fc9516eae 100644
    class Moderators { 
    2121                add_filter( 'bbp_map_primary_meta_caps',        array( $this, 'map_meta_caps' ), 10, 4 );
    2222                add_action( 'bbp_post_request',                 array( $this, 'edit_user_handler' ), 0 );
    2323
     24                // Allow moderators to reply to closed topics (marked as spam for instance)
     25                add_filter( 'bbp_current_user_can_access_create_reply_form', array ( $this, 'allow_create_reply_form_access' ), 10 );
     26
    2427                // Append 'view=all' to forum, topic, and reply URLs in moderator views.
    2528                add_filter( 'bbp_get_forum_permalink',          array( $this, 'add_view_all' ) );
    2629                add_filter( 'bbp_get_topic_permalink',          array( $this, 'add_view_all' ) );
    class Moderators { 
    10201023        public function store_moderator_username( $post_id ) {
    10211024                update_post_meta( $post_id, self::MODERATOR_META, wp_get_current_user()->user_nicename );
    10221025        }
     1026
     1027        /**
     1028         * Allow moderators to reply to closed topics (e.g. marked as spam)
     1029         *
     1030         * @param bool $retval
     1031         * @return bool
     1032         */
     1033        public function allow_create_reply_form_access( $retval ) {
     1034                return current_user_can( 'moderate' ) || $retval;
     1035        }
    10231036}