Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && ($_POST['action']== 'new_post')) {
$has_errors = false;
$title = $_POST['title'];
$tablature = $_POST['tablature'];
$performer = $_POST['performer'];
$composer = $_POST['composer'];
$cat = array( $_POST['cat'] );
if(!isset($title)) { echo '<div class="error">Title required.</div>'; $has_errors = true; }
if(!isset($tablature)) { echo '<div class="error">Description required.</div>'; $has_errors = true; }
if(!isset($performer)) { echo '<div class="error">Performer required.</div>'; $has_errors = true; }
if(!isset($composer)) { echo '<div class="error">Composer required.</div>'; $has_errors = true; }
if($cat == -1) { echo '<div class="error">Please select a category.</div>'; $has_errors = true; }
$tags = $_POST['post_tags'];
if (!$has_errors){
// Save <title> by: <performer>
$title .= " by " .$performer;
// Save Composed by: <composer> Performed by: <performer> <tablature>
$content = "<h4>Composed by: ".$composer."</h4><h4>Performed by: ".$performer."</h4><p>Posted by: <?php the_author(); ?></p>
<br/>".$tablature;
global $current_user;
get_currentuserinfo();
$new_post = array(
'post_title' => $title,
'post_content' => $content,
'post_category' => $cat,
'post_author' => $current_user->ID,
'post_status' => 'draft'
);
wp_insert_post($new_post);
// save email and submitter as post meta in custom fields
wp_redirect( home_url('/thank-you/') );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.