Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: group creation error: Are you sure you want to do this?


Josh McKenney
Participant

@jmckenney

well, I had to do some hacking in when and how it would reset the cookies… from this:
`
/* If no current step is set, reset everything so we can start a fresh group creation */
if ( !$bp->groups->current_create_step = $bp->action_variables[1] ) {

unset( $bp->groups->current_create_step );
unset( $bp->groups->completed_create_steps );
setcookie( ‘bp_new_group_id’, false, time() – 1000, COOKIEPATH );
setcookie( ‘bp_completed_create_steps’, false, time() – 1000, COOKIEPATH );
$reset_steps = true;
bp_core_redirect( $bp->root_domain . ‘/’ . $bp->groups->slug . ‘/create/step/’ . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . ‘/’ );
}

/* If this is a creation step that is not recognized, just redirect them back to the first screen */
if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
bp_core_add_message( __(‘There was an error saving group details. Please try again.’, ‘buddypress’), ‘error’ );
bp_core_redirect( $bp->root_domain . ‘/’ . $bp->groups->slug . ‘/create/’ );
}

/* Fetch the currently completed steps variable */
if ( isset( $_COOKIE ) && !$reset_steps ) {
$bp->groups->completed_create_steps = unserialize( stripslashes( $_COOKIE ) );
}

/* Set the ID of the new group, if it has already been created in a previous step */
if ( isset( $_COOKIE ) ) {
$bp->groups->new_group_id = $_COOKIE;
$bp->groups->current_group = new BP_Groups_Group( $bp->groups->new_group_id );
}
`
to:
`
/* If no current step is set, reset everything so we can start a fresh group creation */
if ( !$bp->groups->current_create_step = $bp->action_variables[1] ) {

unset( $bp->groups->current_create_step );
unset( $bp->groups->completed_create_steps );
//setcookie( ‘bp_new_group_id’, false, time() – 1000, COOKIEPATH );
//setcookie( ‘bp_completed_create_steps’, false, time() – 1000, COOKIEPATH );
$reset_steps = true;
bp_core_redirect( $bp->root_domain . ‘/’ . $bp->groups->slug . ‘/create/step/’ . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . ‘/’ );
} else {
/* Set the ID of the new group, if it has already been created in a previous step */
if ( isset( $_COOKIE ) ) {
$bp->groups->new_group_id = $_COOKIE;
$bp->groups->current_group = new BP_Groups_Group( $bp->groups->new_group_id );
}
}

/* If this is a creation step that is not recognized, just redirect them back to the first screen */
if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
bp_core_add_message( __(‘There was an error saving group details. Please try again.’, ‘buddypress’), ‘error’ );
bp_core_redirect( $bp->root_domain . ‘/’ . $bp->groups->slug . ‘/create/’ );
}

/* Fetch the currently completed steps variable */
if ( isset( $_COOKIE ) && !$reset_steps ) {
$bp->groups->completed_create_steps = unserialize( stripslashes( $_COOKIE ) );
}
`

inside bp_groups.php inside buddypress plugin. Finally works for me…

Notice I completely removed the need to set the cookie with a past date (deleting it) and instead just check for an existing cookie AFTER the first step.

Skip to toolbar