Making WordPress.org

Changeset 4026


Ignore:
Timestamp:
09/10/2016 01:36:00 PM (7 years ago)
Author:
jmdodd
Message:

Support Forums: Allow plugin/theme authors to set topic resolutions on their forum.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

    r4023 r4026  
    168168                add_action( 'wporg_compat_single_topic_sidebar_pre', array( $this, 'do_topic_sidebar' ) );
    169169
     170                // Handle topic resolution permissions.
     171                add_filter( 'wporg_bbp_user_can_resolve', array( $this, 'user_can_resolve' ), 10, 3 );
     172
    170173                // Instantiate WPORG_Ratings compat mode for reviews.
    171174                if ( class_exists( 'WPORG_Ratings' ) && class_exists( 'WordPressdotorg\Forums\Ratings_Compat' ) ) {
     
    176179            }
    177180        }
     181    }
     182
     183    /**
     184     * Allow plugin/theme authors to resolve a topic on their support forum.
     185     *
     186     * @param bool $retval If the user can set a topic resolution for the topic
     187     * @param int $user_id The user id
     188     * @param int $topic_id The topic id
     189     * @return bool True if the user can set the topic resolution, otherwise false
     190     */
     191    public function user_can_resolve( $retval, $user_id, $topic_id ) {
     192        $user = get_userdata( $user_id );
     193        if ( $user && ! empty( $this->authors ) && in_array( $user->user_login, $this->authors ) ) {
     194            $retval = true;
     195        }
     196        return $retval;
    178197    }
    179198
Note: See TracChangeset for help on using the changeset viewer.