Changeset 5631
- Timestamp:
- 07/08/2017 12:48:54 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php
r5621 r5631 17 17 // Scripts and styles. 18 18 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); 19 20 // Allow keymasters and moderators to edit users. 21 add_filter( 'bbp_map_primary_meta_caps', array( $this, 'map_meta_caps' ), 10, 4 ); 19 22 20 23 // Append 'view=all' to forum, topic, and reply URLs in moderator views. … … 119 122 wp_enqueue_style( 'support-forums-moderators', plugins_url( 'css/styles-moderators.css', __DIR__ ) ); 120 123 } 124 } 125 126 /** 127 * Allow keymasters and moderators to edit users without having 128 * an Administrator role on the site. 129 * 130 * @param array $caps User's actual capabilities. 131 * @param string $cap Capability name. 132 * @param int $user_id Current user ID. 133 * @param array $args Capability context, typically the object ID. 134 * @return array Filtered capabilities. 135 */ 136 function map_meta_caps( $caps, $cap, $user_id, $args ) { 137 switch ( $cap ) { 138 case 'promote_user': 139 case 'promote_users': 140 // Only keymasters can promote users. 141 $caps = array( 'keep_gate' ); 142 break; 143 144 case 'edit_user': 145 case 'edit_users': 146 // Bail before "User Role" section is displayed. 147 // See https://bbpress.trac.wordpress.org/ticket/3126 148 if ( did_action( 'bbp_user_edit_after_account' ) && ! bbp_is_user_keymaster( $user_id ) ) { 149 return $caps; 150 } 151 152 // Get the user ID. 153 $_user_id = ! empty( $args[0] ) 154 ? (int) $args[0] 155 : bbp_get_displayed_user_id(); 156 157 // Users can always edit themselves, so only map for others. 158 if ( ! empty( $_user_id ) && ( $_user_id !== $user_id ) ) { 159 160 // Moderators cannot edit keymasters. 161 if ( ! bbp_is_user_keymaster( $_user_id ) ) { 162 $caps = array( 'moderate' ); 163 } 164 } 165 break; 166 } 167 168 return $caps; 121 169 } 122 170
Note: See TracChangeset
for help on using the changeset viewer.