secret
Last active

  • Download Gist
gistfile1.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
<!-- 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']));
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.