# jetformbuilder/3.6.6/modules/actions-v2/insert-post/properties/insert-action.php

JetFormBuilder — Dynamic Blocks Form Builder, version 3.6.6. 44 lines.

- Page: https://pluginprobe.com/plugins/jetformbuilder/3.6.6/code/modules/actions-v2/insert-post/properties/insert-action.php
- Raw: https://pluginprobe.com/plugins/jetformbuilder/3.6.6/raw/modules/actions-v2/insert-post/properties/insert-action.php
- Modified: 2024-08-13T13:45:00+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/jetformbuilder/3.6.6/code/modules/actions-v2/insert-post/properties/insert-action.php#L10-L20`.

```php
<?php


namespace JFB_Modules\Actions_V2\Insert_Post\Properties;

use Jet_Form_Builder\Actions\Methods\Abstract_Modifier;
use Jet_Form_Builder\Exceptions\Action_Exception;

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}

class Insert_Action extends Base_Post_Action {

	public function get_id(): string {
		return 'insert';
	}

	public static function is_supported( Abstract_Modifier $modifier ): bool {
		return true;
	}

	/**
	 * @throws Action_Exception
	 */
	public function do_action() {
		if ( ! $this->pre_check() ) {
			return;
		}

		$this->inserted_id = wp_insert_post( $this->modifier->source_arr, true );

		if ( ! is_wp_error( $this->inserted_id ) ) {
			return;
		}

		throw new Action_Exception(
			'failed',
			esc_html( $this->inserted_id->get_error_message() )
		);
	}
}

```
