trumpeter

Tribe_events submission

Oct 2nd, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.86 KB | None | 0 0
  1. $postTitleError = '';
  2.  
  3. if(isset($_POST['submitted']) && isset($_POST['post_nonce_field']) && wp_verify_nonce($_POST['post_nonce_field'], 'post_nonce')) {
  4.  
  5.     if(trim($_POST['postTitle']) === '') {
  6.         $postTitleError = 'Please enter a title.';
  7.         $hasError = true;
  8.     } else {
  9.         $postTitle = trim($_POST['postTitle']);
  10.     }
  11.  
  12.  
  13.     $post_information = array(
  14.         'post_title' => esc_attr(strip_tags($_POST['postTitle'])),
  15.         'post_content' => esc_attr(strip_tags($_POST['postContent'])),
  16.         'post_type' => 'tribe_events',
  17.         'post_status' => 'pending'
  18.     );
  19.  
  20.     $post_id = wp_insert_post($post_information);
  21.  
  22.     if($post_id)
  23.     {
  24.         wp_redirect(home_url());
  25.         exit;
  26.     }
  27.  
  28. }
  29.  
  30. ?>
  31.  
  32. <?php get_header(); ?>
  33.  
  34.  
  35.     <!-- #primary BEGIN -->
  36.     <div id="primary">
  37.  
  38.         <form action="" id="primaryPostForm" method="POST">
  39.  
  40.             <fieldset>
  41.  
  42.                 <label for="postTitle"><?php _e('Post\'s Title:', 'framework') ?></label>
  43.  
  44.                 <input type="text" name="postTitle" id="postTitle" value="<?php if(isset($_POST['postTitle'])) echo $_POST['postTitle'];?>" class="required" />
  45.  
  46.             </fieldset>
  47.  
  48.             <?php if($postTitleError != '') { ?>
  49.                 <span class="error"><?php echo $postTitleError; ?></span>
  50.                 <div class="clearfix"></div>
  51.             <?php } ?>
  52.  
  53.             <fieldset>
  54.                        
  55.                 <label for="postContent"><?php _e('Post\'s Content:', 'framework') ?></label>
  56.  
  57.                 <textarea name="postContent" id="postContent" rows="8" cols="30"><?php if(isset($_POST['postContent'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['postContent']); } else { echo $_POST['postContent']; } } ?></textarea>
  58.  
  59.             </fieldset>
  60.  
  61.             <fieldset>
  62.                
  63.                 <?php wp_nonce_field('post_nonce', 'post_nonce_field'); ?>
  64.  
  65.                 <input type="hidden" name="submitted" id="submitted" value="true" />
  66.                 <button type="submit"><?php _e('Add Post', 'framework') ?></button>
  67.  
  68.             </fieldset>
  69.  
  70.         </form>
  71.  
  72.     </div><!-- #primary END -->
Add Comment
Please, Sign In to add comment