-
-
Save zacparker/35ad2c03a340bb324109 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- New Post Form --> | |
<div id="postbox"> | |
<form id="new_post" name="new_post" method="post" action=""> | |
<p><label for="submitter">Submitted By</label><br /> | |
<input type="text" id="submitter" value="" tabindex="1" size="20" name="submitter" /> | |
</p> | |
<p><label for="email">Email Address</label><br /> | |
<input type="text" id="email" value="" tabindex="2" size="20" name="email" /> | |
</p> | |
<p><label for="title">Song Title</label><br /> | |
<input type="text" id="title" value="" tabindex="3" size="20" name="title" /> | |
</p> | |
<p><label for="composer">Composed By</label><br /> | |
<input type="text" id="composer" value="" tabindex="5" size="20" name="composer" /> | |
</p> | |
<p><label for="performer">Performed By</label><br /> | |
<input type="text" id="performer" value="" tabindex="5" size="20" name="performer" /> | |
</p> | |
<p><label for="tablature">Song Body</label><br /> | |
<textarea id="tablature" tabindex="6" name="tablature" cols="50" rows="6"></textarea> | |
</p> | |
<p><select name="categories" size="1" tabindex="7"> | |
<option value="8">Hawaiian Mele</option> | |
<option value="9">Local Jams</option> | |
<option value="6">Personal Songs</option> | |
<option value="7">Tablature</option> | |
</select></p> | |
<p align="right"><input type="submit" value="Publish" tabindex="8" id="submit" name="submit" /></p> | |
<input type="hidden" name="action" value="new_post" /> | |
<?php wp_nonce_field( 'new-post' ); ?> | |
</form> | |
</div> | |
<!--// New Post Form --> | |
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && ($_POST['action']== 'new_post')) { | |
$has_errors = false; | |
if (isset ($_POST['title'])) { | |
$title = $_POST['title']; | |
} else { | |
echo 'Please enter a song title'; | |
$has_errors = true; | |
} | |
if (isset ($_POST['performer'])) { | |
$performer = $_POST['performer']; | |
} else { | |
echo 'Please enter a performer'; | |
$has_errors = true; | |
} | |
if (isset ($_POST['composer'])) { | |
$composer = $_POST['composer']; | |
} else { | |
echo 'Please enter a composer'; | |
$has_errors = true; | |
} | |
if (isset ($_POST['tablature'])) { | |
$tablature = $_POST['tablature']; | |
} else { | |
echo 'Please enter the content'; | |
$has_errors = true; | |
} | |
$tags = $_POST['post_tags']; | |
if (!$has_errors){ | |
//save <title> by: <performer> | |
$title .= " by ".$performer = $_POST['title']; | |
//save Composed by: <composer> Performed by: <performer> <tablature> | |
$content = "<h4>Composed by: ". $composer."</h4><br/><h4>Performed by: ".$performer."</h4><br/>".$tablature; | |
$new_post = array( | |
'post_title' => $title, | |
'post_content' => $content, | |
'post_category' => $_POST['cat'], | |
'tags_input' => $tags, | |
'post_status' => 'draft' | |
); | |
$pid = wp_insert_post($new_post); | |
//save email and submmiter as post meta in custom fields | |
update_post_meta($pid, 'submitter_email', urldecode($_POST['email'])); | |
update_post_meta($pid, 'submitter_name', urldecode($_POST['submitter'])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment