| @@ -15,9 +15,9 @@ | ||
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Output the forum-role field when adding a new user |
| 18 | 18 | * |
| 19 | - * @since 2.6.0 bbPress (r6674) | |
| 19 | + * @since 2.6.0 bbPress (r6675) | |
| 20 | 20 | */ |
| 21 | 21 | function bbp_add_user_form_role_field() { |
| 22 | 22 | |
| 23 | 23 | // Bail if current user cannot promote users |
| @@ -61,9 +61,9 @@ | ||
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * Maybe add forum role to signup meta array |
| 64 | 64 | * |
| 65 | - * @since 2.6.0 bbPress (r6674) | |
| 65 | + * @since 2.6.0 bbPress (r6675) | |
| 66 | 66 | * |
| 67 | 67 | * @param array $meta |
| 68 | 68 | * |
| 69 | 69 | * @return array |
| @@ -97,9 +97,9 @@ | ||
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * Add forum meta data when inviting a user to a site |
| 100 | 100 | * |
| 101 | - * @since 2.6.0 bbPress (r6674) | |
| 101 | + * @since 2.6.0 bbPress (r6675) | |
| 102 | 102 | * |
| 103 | 103 | * @param int $user_id The invited user's ID. |
| 104 | 104 | * @param array $role The role of invited user. |
| 105 | 105 | * @param string $newuser_key The key of the invitation. |
| @@ -134,9 +134,9 @@ | ||
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | 136 | * Single-site handler for adding a new user |
| 137 | 137 | * |
| 138 | - * @since 2.6.0 bbPress (r6674) | |
| 138 | + * @since 2.6.0 bbPress (r6675) | |
| 139 | 139 | * |
| 140 | 140 | * @param int $user_id |
| 141 | 141 | */ |
| 142 | 142 | function bbp_user_add_role_on_register( $user_id = '' ) { |
| @@ -160,9 +160,9 @@ | ||
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | 162 | * Multi-site handler for adding a new user |
| 163 | 163 | * |
| 164 | - * @since 2.6.0 bbPress (r6674) | |
| 164 | + * @since 2.6.0 bbPress (r6675) | |
| 165 | 165 | * |
| 166 | 166 | * @param int $user_id User ID. |
| 167 | 167 | */ |
| 168 | 168 | function bbp_user_add_role_on_activate( $user_id = 0, $password = '', $meta = array() ) { |
| @@ -193,9 +193,9 @@ | ||
| 193 | 193 | * the logic used to validate if a Forum Role is valid, typically during new |
| 194 | 194 | * user registration, but also when adding an existing user to a site in |
| 195 | 195 | * Multisite installations. |
| 196 | 196 | * |
| 197 | - * @since 2.6.5 | |
| 197 | + * @since 2.6.5 bbPress (r7087) | |
| 198 | 198 | * |
| 199 | 199 | * @param string $to_validate A role ID to validate |
| 200 | 200 | * @return string A valid role ID, or empty string on error |
| 201 | 201 | */ |
| @@ -225,9 +225,9 @@ | ||
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | 227 | * Validate the Forum role during the registration process |
| 228 | 228 | * |
| 229 | - * @since 2.6.5 | |
| 229 | + * @since 2.6.5 bbPress (r7087) | |
| 230 | 230 | * |
| 231 | 231 | * @param string $to_validate A well-formed (string) role ID to validate |
| 232 | 232 | * @return string A valid role ID, or empty string on error |
| 233 | 233 | */ |
| @@ -235,10 +235,10 @@ | ||
| 235 | 235 | |
| 236 | 236 | // Default return value |
| 237 | 237 | $retval = bbp_get_default_role(); |
| 238 | 238 | |
| 239 | - // Conditionally handle posted values for capable users | |
| 240 | - if ( is_admin() && current_user_can( 'create_users' ) ) { | |
| 239 | + // Conditionally handle posted values for capable users. Only keymasters can assign keymasters. | |
| 240 | + if ( is_admin() && ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) && ( bbp_is_user_keymaster() || ( bbp_get_keymaster_role() !== $to_validate ) ) ) { | |
| 241 | 241 | $retval = $to_validate; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // Validate & return |
| @@ -250,9 +250,9 @@ | ||
| 250 | 250 | * |
| 251 | 251 | * This function exists simply for parity with registrations, and to maintain an |
| 252 | 252 | * intentional layer of abstraction from the more generic function it uses. |
| 253 | 253 | * |
| 254 | - * @since 2.6.5 | |
| 254 | + * @since 2.6.5 bbPress (r7087) | |
| 255 | 255 | * |
| 256 | 256 | * @param string $to_validate A well-formed (string) role ID to validate |
| 257 | 257 | * @return string A valid role ID, or empty string on error |
| 258 | 258 | */ |