Skip to:
Content
Pages
Categories
Search
Top
Bottom

trouble with trying to create a custom group field

  • Hi, am new to buddypress and know basic php etc
    Have successfully installed it all and have been modifying for my own use.

    One of the mods I am trying to do is simply add one extra field to the main details of the group.

    I read up on the group extension api but seemed to be a little more complicated to go with, so just decided to go in and add an extra input field and value to be worked through the registration/update system.
    Basically wherever I found the current ‘description’ I added an extra field ‘tally’ (i want the group to have a tally of items made), and then also replicated all description handling code with additional ‘tally’ handling code.
    for now am just working with this as a string and even passing it into the database to a field called ‘tally’ which is varchar. however at some point will be best to have this as an int in the database, but for ease of use whilst doing this have kept to strings.

    I am pretty sure I have completely added all the necessary ‘tally’ bits throughout where needed, create.php – bp-groups.php etc.

    Where it is falling down is an error (I have asked it to elaborate a little with some custom error reporting. here it is in the bp-groups.php…

    `
    /* If the save, upload or skip button is hit, lets calculate what we need to save */
    if ( isset( $_POST ) ) {

    /* Check the nonce */
    check_admin_referer( ‘groups_create_save_’ . $bp->groups->current_create_step );

    if ( ‘group-details’ == $bp->groups->current_create_step ) {
    if ( empty( $_POST ) || empty( $_POST ) || empty( $_POST ) || !strlen( trim( $_POST ) ) || !strlen( trim( $_POST ) ) || !strlen( trim( $_POST ) ) ) {
    /*bp_core_add_message( __( ‘please fill in all of the required fields. aa’, ‘buddypress’ ), ‘error’ );*/
    bp_core_add_message( __( ‘fields were (empty) name – ‘ . $_POST . ‘ tally – ‘ . $_POST . ‘ description – ‘ . $_POST, ‘buddypress’ ), ‘error’ );
    bp_core_redirect( $bp->root_domain . ‘/’ . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step . ‘/’ );
    }

    if ( !$bp->groups->new_group_id = groups_create_group( array( ‘group_id’ => $bp->groups->new_group_id, ‘name’ => $_POST, ‘tally’ => $_POST, ‘description’ => $_POST, ‘slug’ => groups_check_slug( sanitize_title( esc_attr( $_POST ) ) ), ‘date_created’ => gmdate( “Y-m-d H:i:s” ), ‘status’ => ‘public’ ) ) ) {
    /*bp_core_add_message( __( ‘there was an error saving pod details, please try again.’, ‘buddypress’ ), ‘error’ );*/
    bp_core_add_message( __( ‘fields were (error) name – ‘ . $_POST . ‘ tally – ‘ . $_POST . ‘ description – ‘ . $_POST, ‘buddypress’ ), ‘error’ );
    bp_core_redirect( $bp->root_domain . ‘/’ . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step . ‘/’ );
    }

    groups_update_groupmeta( $bp->groups->new_group_id, ‘total_member_count’, 1 );
    groups_update_groupmeta( $bp->groups->new_group_id, ‘last_activity’, gmdate( “Y-m-d H:i:s” ) );
    }`

    It’s the `bp_core_add_message( __( ‘fields were (error) name – ‘…..` bit, all the fields print out the correct values.
    It seems that the error is because it checks that the data was stored properly before moving on. If I comment this out obviously no error but the is no entry made to the database. somewhere it is bawking at the new field data and not passing it on. any ideas? (i know there are a lot of possible reasons but any pointers of the line of ‘submitting’ the data to the database would be very helpful!)
    I have spent days trying to get it to work and no luck yet so only post here for help in frustration.

    ps it seems to be pulling this new data succesfully from the db, if going into a groups admin area, be updating throws the same kind of error, so is all to do with pushing this data out to save to the db.

  • The topic ‘trouble with trying to create a custom group field’ is closed to new replies.
Skip to toolbar