# taskbuilder/5.0.7/includes/admin/projects/wppm_create_project.php

Taskbuilder – Project Management &amp; Task Management Tool With Kanban Board, version 5.0.7. 63 lines.

- Page: https://pluginprobe.com/plugins/taskbuilder/5.0.7/code/includes/admin/projects/wppm_create_project.php
- Raw: https://pluginprobe.com/plugins/taskbuilder/5.0.7/raw/includes/admin/projects/wppm_create_project.php
- Modified: 2026-03-26T15:36:34+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/taskbuilder/5.0.7/code/includes/admin/projects/wppm_create_project.php#L10-L20`.

```php
<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
global $wpdb, $wppmfunction, $current_user;
if ( check_ajax_referer( 'wppm_create_project', '_ajax_nonce', false ) != 1 ) {
	wp_send_json_error( 'Unauthorised request!', 401 );
}
$wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true );
if (($current_user->has_cap('manage_options')) || $wppm_current_user_capability == 'wppm_manager'|| $wppm_current_user_capability == 'wppm_admin') {
	// project name
	$name = isset($_POST['name']) ? sanitize_text_field(wp_unslash($_POST['name'])) : '';
	if($name) $args['name'] = $name;

	// Description
	$project_description = '';

	if ( !empty( $_POST['wppm_proj_description'] ) ) {
		$project_description = wp_kses_post(
			wp_unslash( $_POST['wppm_proj_description'] )
		);
	}
	if($project_description) $args['wppm_proj_description'] = $project_description;

	//Project start date
	$text = isset($_POST['wppm_start_date']) ? sanitize_text_field(wp_unslash($_POST['wppm_start_date'])) : '';
	if($text) $args['wppm_start_date'] = wp_date("Y-m-d H:i:s" ,strtotime($text));

	//Project end date
	$text2 = isset($_POST['wppm_end_date']) ? sanitize_text_field(wp_unslash($_POST['wppm_end_date'])) : '';
	if($text2) $args['wppm_end_date'] = wp_date("Y-m-d H:i:s" ,strtotime($text2));

	// Category
	$project_category = isset($_POST['wppm_create_project_category']) ? intval(sanitize_text_field(wp_unslash($_POST['wppm_create_project_category']))) : '';
	if($project_category) $args['wppm_create_project_category'] = $project_category;

	//Assign user
	$users = array();
	if ( isset( $_POST['user_names'] ) && is_array( $_POST['user_names'] ) ) {
		$users = array_map(
			'absint',
			wp_unslash( $_POST['user_names'] )
		);
		$users = array_unique( $users );
	}
	if($users) $args['user_names'] = $wppmfunction->sanitize_array($users);

	//public project
	$public_proj = isset($_POST['wppm_public_project']) ?  1 : 0;

	$args = apply_filters( 'wppm_before_create_project_args', $args);

	$project_id = WPPM_Functions::create_project($args);
	if ( empty( $project_id ) ) {
    	wp_send_json_error( 'Permission denied', 403 );
	}
	$auth_code = $wppmfunction->getRandomString(10);
	$wppmfunction->add_project_meta($project_id,'public_project',$public_proj);
	$wppmfunction->add_project_meta($project_id,'project_auth_code',$auth_code);
}

do_action('wppm_after_project_created',$project_id);

```
