Making WordPress.org


Ignore:
Timestamp:
09/01/2026 07:01:20 PM (5 weeks ago)
Author:
obenland
Message:

Support Forums: use the topic ID passed to user_can_resolve()

Closes ​https://github.com/WordPress/wordpress.org/pull/856.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-topic-resolution/inc/class-plugin.php

    r12459 r15121  
    265265         */
    266266        public function topic_resolution_handler( $action = '' ) {
    267                 if ( ! $this->is_enabled_on_forum() ) {
    268                         return false;
    269                 }
    270 
    271267                // Bail if the action isn't meant for this function.
    272268                if ( $action != 'wporg_bbp_topic_resolution' ) {
    … …  
    284280                $user_id    = get_current_user_id();
    285281                $resolution = $_POST[ self::META_KEY ];
     282
     283                // Resolution must be enabled on the topic's forum, not on the one being viewed.
     284                if ( $topic && ! $this->is_enabled_on_forum( bbp_get_topic_forum_id( $topic->ID ) ) ) {
     285                        return false;
     286                }
    286287
    287288                // Check for empty topic id.
    … …  
    510511         */
    511512        public function user_can_resolve( $user_id, $topic_id ) {
    512                 $post     = false;
    513                 $topic_id = bbp_get_topic_id();
    514                 if ( $topic_id ) {
    515                         $post = get_post( $topic_id );
    516                 }
     513                // Authorize against the requested topic, only falling back to the displayed one.
     514                $topic_id = bbp_get_topic_id( $topic_id );
     515                $post     = $topic_id ? bbp_get_topic( $topic_id ) : false;
    517516
    518517                if ( $user_id && $post && ( user_can( $user_id, 'moderate', $topic_id ) || $user_id == $post->post_author ) ) {
Note: See TracChangeset for help on using the changeset viewer.