WordPress.org

Making WordPress.org

Changeset 8117


Ignore:
Timestamp:
01/21/2019 05:38:26 AM (19 months ago)
Author:
dd32
Message:

Support Forums: User Moderation: Allow modwatched users to edit posts, prior to the topic/reply being approved.

This is a follow up to #4035 where posting a new topic would result in a 404 page rather than the pending thread, simply allowing edits prior to approval seems the easiest solution.
Modwatched users are still unable to edit approved topics/replies as per #4035.

See #4035.
Fixes #4087.

File:
1 edited

Legend:

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

    r8041 r8117  
    6565
    6666            // Prevent editing their topics/replies.
    67             add_filter( 'bbp_map_meta_caps', array( $this, 'bbp_map_meta_caps' ), 100, 3 );
     67            add_filter( 'bbp_map_meta_caps', array( $this, 'bbp_map_meta_caps' ), 100, 4 );
    6868        }
    6969
     
    315315    }
    316316
    317     public function bbp_map_meta_caps( $caps, $cap, $user_id ) {
     317    public function bbp_map_meta_caps( $caps, $cap, $user_id, $args ) {
    318318        $limited_caps = array(
    319319            'edit_topic',
     
    322322
    323323        if ( in_array( $cap, $limited_caps, true ) ) {
    324             $caps = array( 'do_not_allow' );
     324            $do_not_allow = array( 'do_not_allow' );
     325
     326            if ( ! isset( $args[0] ) ) {
     327                // No post was specified.. Do not allow editing of an unknown.
     328                $caps = $do_not_allow;
     329            } else {
     330                // If we can't find the post OR the post is NOT pending.. do not allow
     331                $_post = get_post( $args[0] );
     332                if ( ! $_post || $_post->post_status !== bbp_get_pending_status_id() ) {
     333                    $caps = $do_not_allow;
     334                }
     335                // else {
     336                //  // We found the post, and it's status is pending.. fall-through and allow.
     337                // }
     338            }
    325339        }
    326340
Note: See TracChangeset for help on using the changeset viewer.