Making WordPress.org


Ignore:
Timestamp:
03/02/2022 07:51:58 AM (3 years ago)
Author:
dd32
Message:

Support: User Blocking: When blocking a user, add where they've been blocked from, and context if possible.

Fixes #5764.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/ui.php

    r11622 r11623  
    140140        if ( $block_words ) {
    141141            $block_words = explode( "\n", $block_words );
    142             $block_words = array_values( array_unique( array_filter( array_map( 'trim', $block_words ) ) ) );
     142            $block_words = array_values( array_unique( array_filter( $block_words ) ) );
    143143
    144144            // Sanity; Don't let it change more than 20%.
     
    190190        '<tr>
    191191            <th>reCaptcha v3 low-score threshold for Registration</th>
    192             <td><input name="recaptcha_v3_threshold" type="number" min="0.0" max="1.0" step="0.1" name="" value="%s"></td>
     192            <td>
     193                <input name="recaptcha_v3_threshold" type="number" min="0.0" max="1.0" step="0.1" name="" value="%s">
     194                <p><em>Any reCaptcha v3 score lower than this threshold is considered to have failed the reCaptcha and will be put into manual review.</em></p>
     195            </td>
    193196        </tr>',
    194197        esc_attr( get_option( 'recaptcha_v3_threshold', 0.2 ) )
     
    200203            <td>
    201204                <textarea name="registration_block_words" rows="10" cols="80">%s</textarea>
    202                 <p><em>Any registrations with any of these phrases within their username, email address, or profile fields will be put into manual review. One phrase per line.</em></p>
     205                <p>
     206                    <em>Any registrations with any of these phrases within their username, email address, or profile fields will be put into manual review.</em><br>
     207                    <em>Multiple words allowed to form a phrase. Leading/trailing whitespace is not removed. One phrase per line.</em>
     208                </p>
    203209            </td>
    204210        </tr>',
     
    356362    }
    357363
    358     if ( empty( $_REQUEST['user_id'] ) ) {
     364    if ( empty( $_REQUEST['user'] ) ) {
    359365        die();
    360366    }
    361367
    362     $user_id = (int) $_REQUEST['user_id'];
    363 
    364     check_admin_referer( 'block_account_' . $user_id );
    365 
    366     if ( $user_id && defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) {
     368    $pending_user = wporg_get_pending_user( $_REQUEST['user'] );
     369    if ( ! $pending_user || ! $pending_user['created'] ) {
     370        die();
     371    }
     372
     373    $user = get_user_by( 'slug', $pending_user['user_login'] );
     374    if ( ! $user ) {
     375        die();
     376    }
     377
     378    $table = new User_Registrations_List_Table();
     379
     380    ob_start();
     381    $pending_as_object       = (object) $pending_user;
     382    $pending_as_object->meta = (object) $pending_as_object->meta;
     383    $pending_as_object->user = $user;
     384
     385    unset( $pending_as_object->meta->registration_ip, $pending_as_object->meta->confirmed_ip );
     386
     387    $table->column_meta( $pending_as_object );
     388    $meta_column = ob_get_clean();
     389    $meta_column = wp_strip_all_tags( str_replace( '<br>', "\n", $meta_column ), false );
     390
     391    check_admin_referer( 'block_account_' . $user->ID );
     392
     393    if ( $user && defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) {
    367394
    368395        // Switch first so that bbPress loads with the correct context.
     
    379406        switch_to_blog( WPORG_SUPPORT_FORUMS_BLOGID );
    380407
     408        add_filter( 'wporg_bbp_forum_role_changed_note_text', function( $text ) use ( $meta_column ) {
     409            return trim( "{$meta_column}\n\n{$text}" );
     410        } );
     411
    381412        // Set the user to blocked. Support forum hooks will take care of the rest.
    382         bbp_set_user_role( $user_id, bbp_get_blocked_role() );
     413        bbp_set_user_role( $user->ID, bbp_get_blocked_role() );
    383414
    384415        restore_current_blog();
Note: See TracChangeset for help on using the changeset viewer.