BBP_Forums_Group_Extension::create_screen_save( $group_id )
Save the Group Forum data on create
Description
Source
File: bp-forums/groups.php
public function create_screen_save( $group_id = 0 ) { // Nonce check if ( ! bbp_verify_nonce_request( 'groups_create_save_' . $this->slug ) ) { bbp_add_error( 'bbp_create_group_forum_screen_save', __( '<strong>ERROR</strong>: Are you sure you wanted to do that?', 'buddyboss' ) ); return; } // Check for possibly empty group_id if ( empty( $group_id ) ) { $group_id = bp_get_new_group_id(); } $create_forum = !empty( $_POST['bbp-create-group-forum'] ) ? true : false; $forum_id = 0; $forum_ids = bbp_get_group_forum_ids( $group_id ); if ( !empty( $forum_ids ) ) $forum_id = (int) is_array( $forum_ids ) ? $forum_ids[0] : $forum_ids; // Create a forum, or not switch ( $create_forum ) { case true : // Bail if initial content was already created if ( !empty( $forum_id ) ) return; // Set the default forum status switch ( bp_get_new_group_status() ) { case 'hidden' : $status = bbp_get_hidden_status_id(); break; case 'private' : $status = bbp_get_private_status_id(); break; case 'public' : default : $status = bbp_get_public_status_id(); break; } // Create the initial forum $forum_id = bbp_insert_forum( array( 'post_parent' => bbp_get_group_forums_root_id(), 'post_title' => bp_get_new_group_name(), 'post_content' => bp_get_new_group_description(), 'post_status' => $status ) ); // Run the BP-specific functions for new groups $this->new_forum( array( 'forum_id' => $forum_id ) ); // Update forum active groups_update_groupmeta( bp_get_new_group_id(), '_bbp_forum_enabled_' . $forum_id, true ); // Toggle forum on $this->toggle_group_forum( bp_get_new_group_id(), true ); break; case false : // Forum was created but is now being undone if ( !empty( $forum_id ) ) { // Delete the forum wp_delete_post( $forum_id, true ); // Delete meta values groups_delete_groupmeta( bp_get_new_group_id(), 'forum_id' ); groups_delete_groupmeta( bp_get_new_group_id(), '_bbp_forum_enabled_' . $forum_id ); // Toggle forum off $this->toggle_group_forum( bp_get_new_group_id(), false ); } break; } }
Changelog
Version | Description |
---|---|
bbPress (r3465) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.