bbp_maybe_create_group_forum_root()

Handle the new group forum root creation


Description Description


Return Return

()


Top ↑

Source Source

File: includes/extend/buddypress/functions.php

function bbp_maybe_create_group_forum_root() {

	// Bail if no nonce
	if ( empty( $_GET['_wpnonce'] ) || ( empty( $_GET['create'] ) || ( 'bbp-group-forum-root' !== $_GET['create'] ) ) ) {
		return;
	}

	// Bail if user cannot publish forums
	if ( ! current_user_can( 'publish_forums' ) ) {
		return;
	}

	// Bail if nonce check fails
	if ( ! wp_verify_nonce( $_GET['_wpnonce'], '_bbp_group_forums_root_id' ) ) {
		return;
	}

	// Create new forum
	$forum_id = bbp_insert_forum(

		// Post
		array( 'post_title' => esc_html__( 'Group Forums', 'bbpress' ) ),

		// Meta
		array( 'forum_type' => 'category' )
	);

	// Update & redirect
	if ( ! empty( $forum_id ) ) {

		// Create
		update_option( '_bbp_group_forums_root_id', $forum_id );

		// Redirect
		bbp_redirect( add_query_arg( array(
			'page'    => 'bbpress',
			'updated' => true
		), admin_url( 'options-general.php' ) ) );
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.