Making WordPress.org


Ignore:
Timestamp:
01/08/2019 02:55:21 AM (8 years ago)
Author:
dd32
Message:

Support Forums: Moderation: Block users who are on modwatch from editing their threads/replies.

Fixes #4035.

File:
1 edited

Legend:

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

    r5957 r8041  
    6363                        add_filter( 'bbp_new_reply_pre_insert',  array( $this, 'pre_insert' ) );
    6464                        add_filter( 'bbp_edit_reply_pre_insert', array( $this, 'pre_insert' ) );
     65
     66                        // Prevent editing their topics/replies.
     67                        add_filter( 'bbp_map_meta_caps', array( $this, 'bbp_map_meta_caps' ), 100, 3 );
    6568                }
    6669
    … …  
    311314                );
    312315        }
     316
     317        public function bbp_map_meta_caps( $caps, $cap, $user_id ) {
     318                $limited_caps = array(
     319                        'edit_topic',
     320                        'edit_reply',
     321                );
     322
     323                if ( in_array( $cap, $limited_caps, true ) ) {
     324                        $caps = array( 'do_not_allow' );
     325                }
     326
     327                return $caps;
     328        }
    313329}
Note: See TracChangeset for help on using the changeset viewer.