function delete_cp_project($project_id)
{
    global $wpdb, $current_user;
    $cp_auth = $current_user->ID;
    $cp_date = date("Y-m-d H:m:s");
    $title = get_cp_project_title($project_id);
    // Delete project
    $table_name = $wpdb->prefix . "cp_projects";
    $wpdb->query("DELETE FROM {$table_name} WHERE id = {$project_id}");
    // Delete all tasks for project
    $table_name = $wpdb->prefix . "cp_tasks";
    $wpdb->query("DELETE FROM {$table_name} WHERE proj_id = {$project_id}");
    insert_cp_activity($cp_auth, $cp_date, 'deleted', $title, 'project', NULL);
}
<?php

// Add Task
if (isset($_POST['cp_add_task_button'])) {
    check_admin_referer('cp-add-task');
    global $wpdb, $current_user, $cp_email_footer;
    $cp_auth = $current_user->ID;
    $cp_users = esc_html($_POST['user']);
    $cp_date = current_time('mysql');
    $cp_title = esc_html($_POST['cp_title']);
    $cp_details = esc_html($_POST['cp_details']);
    $cp_due_date = $_POST['cp_tasks_due_month'] . "-" . $_POST['cp_tasks_due_day'] . "-" . $_POST['cp_tasks_due_year'];
    $cp_add_title = get_cp_project_title($_POST['cp_add_tasks_project']);
    $cp_add_tasks_project = esc_html($_POST['cp_add_tasks_project']);
    $table_name = $wpdb->prefix . "cp_tasks";
    $results = $wpdb->insert($table_name, array('proj_id' => $cp_add_tasks_project, 'auth' => $cp_auth, 'users' => $cp_users, 'date' => $cp_date, 'title' => $cp_title, 'details' => $cp_details, 'due_date' => $cp_due_date));
    // Retrieve newly created record ID
    $lastid = $wpdb->insert_id;
    // Add activity log record
    insert_cp_activity($cp_auth, $cp_date, 'added', $cp_title, 'task', $lastid);
    // Check if email notifications is enabled
    //if (get_option('cp_email_config')) {
    if (isset($_POST['notify'])) {
        // Send email to user assigned to task
        $user_info = get_userdata($cp_users);
        $cp_email = $user_info->user_email;
        $cp_subject = 'CollabPress: New task assigned to you';
        $cp_message = "Project: " . $cp_add_title . "\n\n";
        $cp_message .= "You have just been assigned the following task by " . $current_user->display_name . "\n\n";
        $cp_message .= "Title: " . $cp_title . "\n";
        $cp_message .= "Details: " . $cp_details . "\n\n";
function list_cp_activity($view_more = NULL)
{
    global $wpdb;
    $table_name = $wpdb->prefix . "cp_activity";
    if ($view_more) {
        $cp_list_activities = $wpdb->get_results("SELECT * FROM {$table_name} WHERE 1 ORDER BY id DESC LIMIT 0,20");
    } else {
        $cp_list_activities = $wpdb->get_results("SELECT * FROM {$table_name} WHERE 1 ORDER BY id DESC LIMIT 0,4");
    }
    if ($cp_list_activities) {
        foreach ($cp_list_activities as $cp_list_activity) {
            $user_info = get_userdata($cp_list_activity->auth);
            echo '<div id="cp-gravatar" style="height:62px;width:62px;background:#F0F0F0;">';
            // Default Gravatar
            $def_gravatar = "http://www.gravatar.com/avatar/c11f04eee71dfd0f49132786c34ea4ff?s=50&d=&r=G&forcedefault=1";
            // User link
            echo '<a href="admin.php?page=cp-dashboard-page&view=userpage&user='******'">';
            // Get Gravatar
            echo get_avatar($user_info->user_email, $size = '50', $default = $def_gravatar);
            echo '</a>';
            echo '</div>';
            if ($cp_list_activity->action == 'created' || $cp_list_activity->action == 'added' || $cp_list_activity->action == 'completed') {
                $activity_color = 'green';
            } else {
                if ($cp_list_activity->action == 'edited') {
                    $activity_color = 'orange';
                } else {
                    if ($cp_list_activity->action == 'deleted') {
                        $activity_color = 'red';
                    } else {
                        if ($cp_list_activity->action == 'reopened') {
                            $activity_color = 'orange';
                        } else {
                            $activity_color = 'black';
                        }
                    }
                }
            }
            echo '<div id="cp-task-summary">';
            echo '<p><strong>Date:</strong> ' . $cp_list_activity->date . '</p>';
            // If this is a task
            if ($cp_list_activity->type == 'task' || $cp_list_activity->type == 'comment' || $cp_list_activity->type == 'completed' || $cp_list_activity->type == 'reopened' && $cp_list_activity->cp_id != 0) {
                $task_project_id = get_cp_task_project_id($cp_list_activity->cp_id);
                $task_project_title = get_cp_project_title($task_project_id);
                echo '<p><strong>Project:</strong> ' . $task_project_title;
                echo '<p><strong>Summary: </strong><a href="admin.php?page=cp-dashboard-page&view=userpage&user='******'">' . $user_info->user_nicename . '</a></strong> <span style="color:' . $activity_color . ';">' . $cp_list_activity->action . '</span> ' . $cp_list_activity->type . ' "<a href="admin.php?page=cp-projects-page&view=project&project=' . $task_project_id . '">' . $cp_list_activity->title . '</a>".</p>';
                // If this is a project
            } else {
                if ($cp_list_activity->type == 'project' && $cp_list_activity->cp_id != 0) {
                    $activity_project_id = $cp_list_activity->cp_id;
                    echo '<p><strong>Summary: </strong><a href="admin.php?page=cp-dashboard-page&view=userpage&user='******'">' . $user_info->user_nicename . '</a></strong> <span style="color:' . $activity_color . ';">' . $cp_list_activity->action . '</span> ' . $cp_list_activity->type . ' "<a href="admin.php?page=cp-projects-page&view=project&project=' . $activity_project_id . '">' . $cp_list_activity->title . '</a>".</p>';
                    // If it's neither then it's been deleted and don't display link
                } else {
                    echo '<p><strong>Summary: </strong><a href="#">' . $user_info->user_nicename . '</a></strong> <span style="color:' . $activity_color . ';">' . $cp_list_activity->action . '</span> ' . $cp_list_activity->type . ' ' . $cp_list_activity->title . '.</p>';
                }
            }
            echo '</div>';
        }
        if (!$view_more) {
            echo '<p><a style="text-decoration:none; color:#D54E21" href="admin.php?page=cp-dashboard-page&view=allactivity">' . __('View More', 'collabpress') . '</a></p>';
        } else {
            echo '<p><a style="text-decoration:none; color:#D54E21" href="admin.php?page=cp-dashboard-page">' . __('Back', 'collabpress') . '</a></p>';
        }
    } else {
        echo "<p>No recent activity...</p>";
    }
}
    function cp_projects_oncontentbox_4_content($data)
    {
        if (check_cp_project_exists(esc_html($_GET['project']))) {
            // Get Edit Project Title
            $cp_edit_project_title = get_cp_project_title(esc_html($_GET['project']));
            // Get Edit Project Description
            $cp_edit_project_details = get_cp_project_details(esc_html($_GET['project']));
            ?>
			<form method="post" action="">
			<?php 
            wp_nonce_field('cp-edit-project');
            ?>

			<table class="form-table">
			<tr class="form-field form-required">
			<th scope="row"><label for="cp_edit_project_title"><?php 
            _e('Title', 'collabpress');
            ?>
 <span class="description"><?php 
            _e('(required)', 'collabpress');
            ?>
</span></label></th>
			<td><input name="cp_edit_project_title" type="text" id="cp_edit_project_title" value="<?php 
            echo stripslashes($cp_edit_project_title);
            ?>
" aria-required="true" /></td>
			</tr>
			<tr class="form-field">
			<th scope="row"><label for="cp_edit_project_details"><?php 
            _e('Details', 'collabpress');
            ?>
</label></th>
			<td><input name="cp_edit_project_details" type="text" id="cp_edit_project_details" value="<?php 
            echo stripslashes($cp_edit_project_details);
            ?>
" /></td>
			</tr>			
			</table>

			<input type="hidden" name="cp_edit_project_id" value="<?php 
            echo esc_html($_GET['project']);
            ?>
">
			<input type="hidden" name="edit_project_options" value="cp_edit_project_title, cp_edit_project_details" />

			<p>
			<input type="submit" class="button-primary" name="cp_edit_project_submit" value="<?php 
            _e('Edit Project', 'collabpress');
            ?>
" />
			</p>

			</form>
		<?php 
        } else {
            echo "<p>" . __("Project doesn't exist...", "collabpress") . "</p>";
        }
    }
function list_cp_users_tasks($userid, $page_name)
{
    global $wpdb;
    $table_name = $wpdb->prefix . "cp_tasks";
    $cp_list_my_tasks = $wpdb->get_results("SELECT * FROM {$table_name} WHERE users = {$userid}");
    if ($cp_list_my_tasks) {
        $my_task_count = '';
        foreach ($cp_list_my_tasks as $task_data) {
            $user_info = get_userdata($userid);
            if ($task_data->status != 1) {
                echo '<div style="height:auto">';
                echo '<div id="cp-gravatar" style="height:62px;width:62px;background:#F0F0F0;">';
                // Default gravatar
                $def_gravatar = "http://www.gravatar.com/avatar/c11f04eee71dfd0f49132786c34ea4ff?s=50&d=&r=G&forcedefault=1";
                // User link
                echo '<a href="admin.php?page=cp-dashboard-page&view=userpage&user='******'">';
                // Get gravatar
                echo get_avatar($user_info->user_email, $size = '50', $default = $def_gravatar);
                echo '</a>';
                echo '</div>';
                echo '<div id="cp-task-summary">';
                echo '<div style="margin-left:75px">';
                if ($task_data->status != 1) {
                    $link = 'admin.php?page=' . $page_name . '&view=userpage&user='******'&completed-task=' . $task_data->id;
                    $link = function_exists('wp_nonce_url') ? wp_nonce_url($link, 'cp-action-complete_task') : $link;
                    ?>
<p><input onclick="window.location='<?php 
                    echo $link;
                    ?>
'; return true;" type='checkbox' name='option1' value='1'><?php 
                } else {
                    // This should never get executed / remove in future version
                    $link = 'admin.php?page=' . $page_name . '&view=userpage&user='******'&reopened-task=' . $task_data->id;
                    $link = function_exists('wp_nonce_url') ? wp_nonce_url($link, 'cp-action-uncomplete_task') : $link;
                    ?>
<p><input onclick="window.location='<?php 
                    echo $link;
                    ?>
'; return true;" type='checkbox' name='option1' value='1'><?php 
                }
                if ($task_data->status == 1) {
                    echo ' <span style="text-decoration:line-through">';
                }
                echo "<strong>" . stripslashes($task_data->title) . "</strong>";
                $today = date("n-d-Y", mktime(date("n"), date("d"), date("Y")));
                $today_totime = strtotime($today);
                $duedate_totime = strtotime($task_data->due_date);
                if ($duedate_totime > $today_totime) {
                    $date_color = "#DB4D4D";
                } else {
                    $date_color = "#33FF99";
                }
                echo " <code style='background:" . $date_color . "'>" . __('Due', 'collabpress') . ": " . $task_data->due_date . "</code>";
                if ($task_data->status == 1) {
                    echo '</span>';
                }
                $link = 'admin.php?page=' . $page_name . '&view=userpage&user='******'&delete-task=' . $task_data->id . '&task-title=' . $task_data->title;
                $link = function_exists('wp_nonce_url') ? wp_nonce_url($link, 'cp-action-delete_task') : $link;
                echo ' <a href="admin.php?page=cp-projects-page&view=edit-task&task=' . $task_data->id . '">edit</a>';
                echo ' <a style="color:#D54E21" href="' . $link . '">delete</a></p>';
                // Display project title
                if ($task_data->proj_id) {
                    echo '<p><strong>' . __('Project:', 'collabpress') . '</strong> ' . get_cp_project_title($task_data->proj_id) . '</p>';
                }
                // If there is a description
                if ($task_data->details) {
                    echo '<p><strong>' . __('Description:', 'collabpress') . '</strong> ' . stripslashes(nl2br($task_data->details)) . '</p>';
                }
                require CP_PLUGIN_DIR . '/cp-core/cp-core-comments.php';
                $my_task_count++;
                echo '</div>';
                echo '</div>';
                echo '</div>';
            } else {
                $cp_completed_tasks[] = $task_data;
            }
        }
        if (isset($cp_completed_tasks)) {
            foreach ($cp_completed_tasks as $cp_completed_task) {
                $user_info = get_userdata($cp_completed_task->users);
                echo '<div style="height:auto">';
                echo '<div id="cp-gravatar" style="height:62px;width:62px;background:#F0F0F0;">';
                // Default gravatar
                $def_gravatar = "http://www.gravatar.com/avatar/c11f04eee71dfd0f49132786c34ea4ff?s=50&d=&r=G&forcedefault=1";
                // User link
                echo '<a href="admin.php?page=cp-dashboard-page&view=userpage&user='******'">';
                // Get gravatar
                echo get_avatar($user_info->user_email, $size = '50', $default = $def_gravatar);
                echo '</a>';
                echo '</div>';
                echo '<div style="background:#eeeeee" id="cp-task-summary">';
                echo '<div style="margin-left:75px">';
                if ($cp_completed_task->status != 1) {
                    // This should never get executed - remove in future version
                    ?>
<p><input onclick="window.location='admin.php?page=<?php 
                    echo $page_name;
                    ?>
view=userpage&user=<?php 
                    echo $user_info->ID;
                    ?>
&completed-task=<?php 
                    echo $cp_completed_task->id;
                    ?>
'; return true;" type='checkbox' name='option1' value='1'><?php 
                } else {
                    $link = 'admin.php?page=' . $page_name . '&view=userpage&user='******'&reopened-task=' . $cp_completed_task->id;
                    $link = function_exists('wp_nonce_url') ? wp_nonce_url($link, 'cp-action-uncomplete_task') : $link;
                    ?>
<p><input onclick="window.location='<?php 
                    echo $link;
                    ?>
'; return true;" type='checkbox' name='option1' value='1'><?php 
                }
                if ($cp_completed_task->status == 1) {
                    echo ' <span style="text-decoration:line-through">';
                }
                echo "<strong>" . stripslashes($cp_completed_task->title) . "</strong>";
                echo " <code>" . __('Due', 'collabpress') . ": " . $cp_completed_task->due_date . "</code>";
                if ($cp_completed_task->status == 1) {
                    echo '</span>';
                }
                $link = 'admin.php?page=' . $page_name . '&view=userpage&user='******'&delete-task=' . $cp_completed_task->id . '&task-title=' . $cp_completed_task->title;
                $link = function_exists('wp_nonce_url') ? wp_nonce_url($link, 'cp-action-delete_task') : $link;
                echo ' <a href="admin.php?page=cp-projects-page&view=edit-task&task=' . $cp_completed_task->id . '">edit</a>';
                echo ' <a style="color:#D54E21" href="' . $link . '">delete</a></p>';
                // Display project title
                if ($cp_completed_task->proj_id) {
                    echo '<p><strong>' . __('Project:', 'collabpress') . '</strong> ' . get_cp_project_title($cp_completed_task->proj_id) . '</p>';
                }
                // If there is a description
                if ($cp_completed_task->details) {
                    echo '<p><strong>' . __('Description:', 'collabpress') . '</strong> ' . stripslashes(nl2br($cp_completed_task->details)) . '</p>';
                }
                require CP_PLUGIN_DIR . '/cp-core/cp-core-comments.php';
                $my_task_count++;
                echo '</div>';
                echo '</div>';
                echo '</div>';
            }
        }
    } else {
        echo '<p>No tasks...</p>';
    }
}