BBP_Forums_Admin::attributes_metabox_save( int $forum_id )

Pass the forum attributes for processing

Description

Parameters

$forum_id

(int) (Required) Forum id

Return

(int) Forum id

Source

File: bp-forums/admin/forums.php

	public function attributes_metabox_save( $forum_id ) {

		if ( $this->bail() ) return $forum_id;

		// Bail if doing an autosave
		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
			return $forum_id;

		// Bail if not a post request
		if ( ! bbp_is_post_request() )
			return $forum_id;

		// Nonce check
		if ( empty( $_POST['bbp_forum_metabox'] ) || !wp_verify_nonce( $_POST['bbp_forum_metabox'], 'bbp_forum_metabox_save' ) )
			return $forum_id;

		// Only save for forum post-types
		if ( ! bbp_is_forum( $forum_id ) )
			return $forum_id;

		// Bail if current user cannot edit this forum
		if ( !current_user_can( 'edit_forum', $forum_id ) )
			return $forum_id;

		// Parent ID
		$parent_id = ( !empty( $_POST['parent_id'] ) && is_numeric( $_POST['parent_id'] ) ) ? (int) $_POST['parent_id'] : 0;

		// Update the forum meta bidness
		bbp_update_forum( array(
			'forum_id'    => $forum_id,
			'post_parent' => (int) $parent_id
		) );

		do_action( 'bbp_forum_attributes_metabox_save', $forum_id );

		return $forum_id;
	}

Changelog

Changelog
Version Description
bbPress (r2746) 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.