Re: Restricting group creation to admins
hey guys i cant seem to figure this one out hey; i’ve tried to patch the bp-groups.php file but i get a
#1 HUNK Failed at 449 – please see my reject file
***************
*** 453,459 ****
bp_core_redirect( $bp->loggedin_user->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[‘group-name’], ‘description’ => $_POST[‘group-desc’], ‘news’ => $_POST[‘group-news’], ‘slug’ => groups_check_slug( sanitize_title($_POST[‘group-name’]) ), ‘date_created’ => time() ) ) ) {
bp_core_add_message( __( ‘There was an error saving group details, please try again.’, ‘buddypress’ ), ‘error’ );
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step );
}
— 453,474 —-
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step );
}
+ $group_details = array(
+ ‘group_id’ => $bp->groups->new_group_id,
+ ‘name’ => $_POST[‘group-name’],
+ ‘description’ => $_POST[‘group-desc’],
+ ‘news’ => $_POST[‘group-news’],
+ ‘slug’ => groups_check_slug( sanitize_title($_POST[‘group-name’]) ),
+ ‘date_created’ => time() );
+
+ /* Allow plugins to halt group creation for whatever reason. On doing this the plugin
+ should use the bp_core_add_message function to inform the user why the group creation
+ has failed.
+ N.B. The data passed in $new_group is unsanitised. */
+ if ( ! apply_filters( ‘bp_allow_create_group’, true, $group_details ) )
+ return bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create’ );
+
+ if ( !$bp->groups->new_group_id = groups_create_group( $group_details ) ) {
bp_core_add_message( __( ‘There was an error saving group details, please try again.’, ‘buddypress’ ), ‘error’ );
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step );
}
i’m not too sure what that means and how it can be fixed?