Skip to:
Content
Pages
Categories
Search
Top
Bottom

User registration fails when multiple options selected in BuddyPress 3.0.0


  • rhwentworth
    Participant

    @rhwentworth

    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.

    if ( isset( $_POST[ ‘field_’ . $field_id ] ) and !is_array( $_POST[ ‘field_’ . $field_id ] ) ) { // FIXED!!
    $_POST[ ‘field_’ . $field_id ] = trim( $_POST[ ‘field_’ . $field_id ] );
    }

    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.

Viewing 6 replies - 1 through 6 (of 6 total)

  • Venutius
    Moderator

    @venutius

    You should raise this on BuddyPrss Trac as a bug.


    Paul Gibbs
    Keymaster

    @djpaul

    Thanks for the details. Keep an eye on https://buddypress.trac.wordpress.org/ticket/7845#ticket


    filehippofree
    Participant

    @filehippofree

    I honestly don’t know of another plugin that does this. I took a look at that version today and it’s not only WordPress 3.0 that it needs to be updated for but some BuddyPress stuff as well.

    Anyone know of a solution to help out Max with this? I’d think this is something others would appreciate as well.
    filehippo

    Thanks!


    Varun Dubey
    Participant

    @vapvarun

    Hi @filehippofree,

    As a Quick fix, You can replace line 91 at following path
    buddypress/bp-members/screens/register.php

    if ( isset( $_POST[ 'field_' . $field_id ] ) ) {
    						$_POST[ 'field_' . $field_id ] = trim( $_POST[ 'field_' . $field_id ] );
    					}

    with

    if ( isset( $_POST[ 'field_' . $field_id ] ) && !is_array( $_POST[ 'field_' . $field_id ] )) {
    						$_POST[ 'field_' . $field_id ] = trim( $_POST[ 'field_' . $field_id ] );
    					}

    pandraka
    Participant

    @pandraka

    Is there a date for a fix to BuddyPress for this issues?


    Venutius
    Moderator

    @venutius

    The Trac ticket will tell you the latest state of play

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘User registration fails when multiple options selected in BuddyPress 3.0.0’ is closed to new replies.
Skip to toolbar