Making WordPress.org


Ignore:
Timestamp:
02/22/2023 12:54:20 AM (2 years ago)
Author:
Clorith
Message:

Support Forums: Check intent before updating user preferences.

The bbPress profile page may be triggered by various scenarios that do not have the full context of a profile edit included.

By introducing a hidden input field in the form areas which need a "yes or no" type response, indicated by checkboxes, we can ensure that these are not unintentionally cleared or set from profile modifications made without the options even being presented to the user.

Props zoonini.
Fixes #6509.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-blocks.php

    r12366 r12412  
    160160        printf(
    161161            '<p>
     162                <input type="hidden" name="can_update_block_editor_preference" value="true">
    162163                <input name="block_editor" id="block_editor" type="checkbox" value="disabled" %s />
    163164                <label for="block_editor">%s</label>
     
    175176     */
    176177    public function bbp_profile_update( $user_id ) {
     178        // Catch profile updates that should not be able to include the "Disable Block Editor" preference, and return early.
     179        if ( ! isset( $_REQUEST['can_update_block_editor_preference'] ) ) {
     180            return;
     181        }
     182
    177183        $disabled = ! empty( $_REQUEST['block_editor'] ) && 'disabled' === $_REQUEST['block_editor'];
    178184
Note: See TracChangeset for help on using the changeset viewer.