Profile Field Setup Cant Add SelectBox Fields

WordPress MU 2.8.6.
Buddypress Version 1.1.2

I Can Add Groups, and can Add Fields of Type Text or MultiLine, but options, Dropdowns, and checkboxes fail with "There was an error saving the field. Please try again"

The Field Saves but The Options for the Field do not.

  • ASPDNoble

    Still not Working after freash Install No Plugins

    There was an error saving the field. Please try again

    When adding Fields of type selectbox, multiselectbox, checkboxes, or any type of multi selection field to the Profile Field Setup I Get
    "There was an error saving the field. Please try again"
    WPMU: 2.8.6
    BP: 1.1.2

    1. The Field Creates but the selections do not
    2. Text Boxes and Multiline text boxes work fine
    3. Adding and Removing Groups works Fine.
    4. I have performed a complete reinstall (No Joy)

    Questions
    a. What Table Holds the Selections for User Defined Multi-Selecion Profile Fields?
    b. Can I just enter the selection values for a field manually, and where?
    c. If I Had many Selection Values e.g. Countries or States, can I Import them? and Where?

    Thanks, Stopped cold and need to figure out what I did as soon as possible.

  • Andrew

    Hiya,

    I'm afraid I don't know what's causing this. It seems other people have experienced this problem though:
    http://buddypress.org/forums/topic/adding-new-field-to-group
    http://buddypress.org/forums/topic/unable-to-add-field

    What I would do if this we're to happen on one of our sites is find the section of code tossing the error message and see why the error is getting tossed.

    Thanks,
    Andrew

  • ASPDNoble

    Thanks Andrew,

    I had Already Seen both of these but am at a loss how to narrow the scope to the section of code tossing the error. Also I Upgraded to 1.1.3 which came out over the holiday and no Joy but this was not mentioned in the release history anyway.

    1. Adding Directly into the Table like the person did in http://buddypress.org/forums/topic/unable-to-add-field does solve the immediate issue but Im not 100% sure of the Values that should be placed in the records of the wp_bp_xprofile_fields. Particularly The expected Value for the Type Field. I used the value "Option" and that seems to work. The rest of the topograhy of the table is self evident.

    2. Its clearly an issue with the Append query / loop that appends the Values to the base Field in wp_bp_xprofile_fields, but I cant find the place where this query / loop exists. I can Only locate the point of failure.

    a. !$group->save() is OK but !$field->save() is not. Maybe I'm just thick but where is the save() Function / Sub Routine?

    b. Further I don't see anything in this function that handles the values associated with the field so I'm confused :slight_frown:

    File: bp-xprofile-admin.php
    function xprofile_admin_manage_field( $group_id, $field_id = null ) {
    global $bp, $wpdb, $message, $groups;

    $field = new BP_XProfile_Field($field_id);
    $field->group_id = $group_id;

    if ( isset($_POST['saveField']) ) {
    if ( BP_XProfile_Field::admin_validate() ) {
    $field->name = wp_filter_kses( $_POST['title'] );
    $field->description = wp_filter_kses( $_POST['description'] );
    $field->is_required = wp_filter_kses( $_POST['required'] );
    $field->type = wp_filter_kses( $_POST['fieldtype'] );
    $field->order_by = wp_filter_kses( $_POST["sort_order_{$field->type}"] );

    $field->field_order = $wpdb->get_var( $wpdb->prepare( "SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id ) );

    if ( !$field->field_order ) {
    $field->field_order = (int) $wpdb->get_var( $wpdb->prepare( "SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id ) );
    $field->field_order++;
    }

    /***THE ISSUE IS HERE BUT I DONT KNOW WHAT TO DO ABOUT IT***

    if ( !$field->save() ) {
    $message = __('There was an error saving the field. Please try again', 'buddypress');
    $type = 'error';

    unset($_GET['mode']);
    xprofile_admin($message, $type);
    } else {
    $message = __('The field was saved successfully.', 'buddypress');
    $type = 'success';

    unset($_GET['mode']);

    do_action( 'xprofile_fields_saved_field', $field );

    $groups = BP_XProfile_Group::get_all();
    xprofile_admin( $message, $type );
    }
    } else {
    $field->render_admin_form($message);
    }
    } else {
    $field->render_admin_form();
    }
    }

  • ASPDNoble

    Andrew,

    Another Piece to My Previous Post. This is more than I wanted to know about PHP and buddy press but once I start something I finish.

    Thanks For Your Help. I Joined premium.wpmudev.org because I found BuddyPress's forum a bit weak and to see if I could find a forum that was actually helpful. So far am very glad I did so.

    Im starting to wonder if this isn't a PHP issue. I banged my head against the wall with wordpress for a week before I determined that much of Wordpress and many themes depend on the ShortCode Option in PHP.ini. This issue feels a lot like that.

    Additional Information:
    I Found the Save() Function but now I cant decide if the issue is that
    - apply_Filters() --- is not functioning
    - do_action( 'xprofile_group_before_save', $this ); --- I'snt Saving
    - or prepare() --- Is not Preparing the Query correctly.

    File:bp-xprofile-classes.php
    function save() {
    global $wpdb, $bp;

    $this->name = apply_filters( 'xprofile_group_name_before_save', $this->name, $this->id );
    $this->description = apply_filters( 'xprofile_group_description_before_save', $this->description, $this->id );

    do_action( 'xprofile_group_before_save', $this );

    if ( $this->id ) {
    $sql = $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s, description = %s WHERE id = %d", $this->name, $this->description, $this->id );
    } else {
    $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_groups} (name, description, can_delete) VALUES (%s, %s, 1)", $this->name, $this->description );
    }

    if ( !$wpdb->query($sql) )
    return false;

    do_action( 'xprofile_group_after_save', $this );

    return true;
    }

  • hexone19

    I found out why this occurs...

    It's your MYSQL set up...it needs to be 5.0 and above. I had this happen to me and i installed and uninstalled WPMU and Buddypress and plugins a million times..then I got the inkling to check my database when I tried to install the buddypress event plugin and i got the same issues..

    I had a feeling it was a 4.0 db and I was right..so I did the install once more in a 5.0 set up and voila! works like a charm now...

    So..check your DB...

  • ASPDNoble

    Thanks for all the Posts. The Solution was bizarre and maybe someone can explain how the field defenition for this field in this table was created wrong by the install.

    Solution:
    1. Open wp_bp_xprofile_fields table in design view
    2. The order_by field default value is Null
    3. The Column Options for the order_by field is set to Not Null

    Basically the Default is Null and the Column option is set to not allow null so the Records for Dropdowns, Options, and Checkboxes cant be saved.

    or

    The Append Loop should be providing a value for order_by and isn't

    1. I was on version 5.1 of MYSQL
    2. Didnt try AddType x-mapp-php5 .php in the htaccess

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.