[insert_php] $category = 7; //dealer ad = 7, member ad = 8, member profile = 9
$category_title = "Dealer Ad";
$max_posts = MAX_DEALER_ADS; //maximum number of posts of this type user can submit

$id = wp_get_current_user()->ID;

//check query params to see if user's deleting a post
if(isset($_GET['delete'])) {
$delete = $_GET['delete'];
$posteroo = get_post($delete);
$post_type_object = get_post_type_object( $posteroo->post_type );
//if ($posteroo->post_author == $id) {
if($posteroo == null) {
echo "Post deleted!"; //or the post was never found in the first place
}
elseif(!current_user_can( $post_type_object->cap->delete_post, $posteroo->ID )) {
echo "You do not have permission to delete that post.
";
}
else {
$ret = wp_delete_post($delete); //This causes the page to reload, so the post will already be deleted.
}
}
else {
$args = array('author' => $id, 'category' => $category, 'post_status' => 'any');
$posts = get_posts($args);
$num_posts = count($posts);

if($num_posts < $max_posts) { echo "Submit a $category_title. This $category_title will be publicly visible.

Please complete the required fields.
Please select your image(s) to upload.
";
} else {
echo "You already have the maximum number of ${category_title}s. To submit a new one, please delete one of your existing ${category_title}s.";
}
echo "
You currently have $num_posts ${category_title}s out of a maximum of $max_posts. ${category_title}s will appear on the website after being approved by an administrator.";
echo "
Your posts:

";
foreach($posts as $post) {
$post_url = get_post_permalink($post->ID);
echo "

";
echo "

";
$delete_url = get_page_link() . "?delete=$post->ID";
$delete = "Delete";
echo "

";
echo "

";
}
echo "

Title Status Content Delete
$post->post_title "; //title
echo ( ($post->post_status === "publish") ? "Approved" : "Pending Approval" ) . "
$post->post_content $delete

";
}

[/insert_php]