#7845 closed defect (bug) (fixed)
User registration fails if multi-option multi-select or checkbox involved
Reported by: | DJPaul | Owned by: | r-a-y |
---|---|---|---|
Milestone: | 3.1.0 | Priority: | normal |
Severity: | normal | Version: | 3.0.0 |
Component: | Registration | Keywords: | has-patch commit |
Cc: |
Description
This is showing up on the forums:
- https://buddypress.org/support/topic/buddypress-3-0-no-new-users-since/#post-273213
- https://buddypress.org/support/topic/user-registration-fails-when-multiple-options-selected-in-buddypress-3-0-0/
That second link by @rhwentworth has a good write-up:
In BuddyPress 3.0.0, there is a bug insofar as if a registration form is submitted and a multi-select or checkbox is involved, and multiple options are present, the registration fails with a run-time error as follows:
.
Warning: trim() expects parameter 1 to be string, array given in /home8/fromchao/public_html/buddypress/wp-content/plugins/buddypress/bp-members/screens/register.php on line 93
.
In my local copy, I patched line 92 to add a check to see if an what was returned is an array, and this eliminated the error for me. Might even be the right fix, as the individual returns in an array shouldn't need trimming.
This problem occurred on a dev test site running WordPress 4.9.6. But, the problem and its cause seem pretty obvious, and not a function of WordPress itself. Just needs to be fixed in the official distribution.
if ( isset( $_POST[ 'field_' . $field_id ] ) and !is_array( $_POST[ 'field_' . $field_id ] ) ) // FIXED!! $_POST[ 'field_' . $field_id ] = trim( $_POST[ 'field_' . $field_id ] );
Attachments (1)
Change History (7)
#3
@
7 years ago
- Keywords has-patch added
- Version set to 3.0.0
01.patch
runs trim()
through post fields that are arrays as well.
If we are only worried about text fields, then we can just go with the simple fix listed in the ticket description.
See #7671 where this was introduced.
Do we want to run
trim()
through the multi-option posted array or just introduce the simpleis_array()
fix as listed in the ticket description?