Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: sherpa edit adventure
- */
- ?>
- <?php /* http://pastebin.com/m73LXuuG */ ?>
- <?php
- //$debug = print_r($_POST, true);
- if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "edit_post" && isset($_POST['postid'])) {
- // echo '1. Got here!';
- $post_to_edit = array();
- $post_to_edit = get_post($_POST['postid']); /* these are the fields that we are editing in the form below. you have to change them to your fields and you can add as many as you need. */
- $title = $_POST['title']; // Adventure Name
- $description = $_POST['description']; // Adventure Description
- $latitude = $_POST['woo_maps_lat']; // Latitude custom field for updating map
- $longitude = $_POST['woo-maps_long']; // Longitude custom field for updating map
- $min_skill = $_POST['skill_levels']; // Update minimum skill level
- $gear_provided = $_POST['gear_provided']; // Update gear provided
- $gear_required = $_POST['gear_required']; // Update gear required
- $food_bev = $_POST['food_beverage']; // Update supplied food/beverages
- $transportation = $_POST['transportation_provided']; // Update provided transportation
- $successurl = home_url('/guide-portal/');
- /* this code will save the title and description into the post_to_edit array */
- $post_to_edit->post_title = $title;
- $post_to_edit->post_content = $description;
- /* honestly i can't really remember why i added this code but it is a must */
- $pid = wp_update_post($post_to_edit);
- /* save taxonomies: post ID, form name, taxonomy name, if it appends(true) or rewrite(false) */
- /* here you have to change the "coupon_categories" and "coupon_tags" to the name of your taxonomies */
- // wp_set_post_terms($pid, array($_POST['cat']),'coupons_categories',false);
- // wp_set_post_terms($pid, array($_POST['post_tags']),'coupons_tags',false);
- //UPDATE CUSTOM FIELDS WITH THE NEW INFO
- //CHANGE TO YOUR CUSTOM FIELDS AND ADD AS MANY AS YOU NEED
- update_post_meta($pid, 'woo_maps_lat', $latitude); // Map latitude
- update_post_meta($pid, 'woo-maps_long', $longitude); // Map longitude
- update_post_meta($pid, 'skill_levels', $min_skill); // Minimum Skill Level
- update_post_meta($pid, 'gear_provided', $gear_provided); // Gear Provided
- update_post_meta($pid, 'gear_required', $gear_required); // Gear Required
- update_post_meta($pid, 'food_beverage', $food_bev); // Food/Beverage
- update_post_meta($pid, 'transportation_provided', $transportation); // Transportation
- //REDIRECT USER WHERE EVER YOU WANT AFTER DONE EDITING
- // echo '2. Got here!';
- // wp_redirect( 'http://sherpademo.co.cc/guide-portal/' );
- // header("Location: http://sherpademo.co.cc/guide-portal/");
- wp_redirect( $successurl );
- } // end check for errors
- ?>
- <?php get_header(); ?>
- <?php include ( TEMPLATEPATH . '/search-form.php' ); ?>
- <?php $post_to_edit = get_post($_POST['postid']); ?>
- <div id="content" class="col-full">
- <div id="main-single" class="col-left">
- <div class="post">
- <!-- EDIT GUIDE PROFILE -->
- <form id="edit_post" name="edit_post" method="post" action="" enctype="multipart/form-data">
- <!-- post name -->
- <fieldset name="name">
- <label for="title">Update Adventure Name:</label><br />
- <input type="text" id="title" value="<?php echo $post_to_edit->post_title; ?>" tabindex="5" name="title" /> <!-- TITLE FIELD. NOTHING TO CHANGE -->
- </fieldset>
- <!-- post Content -->
- <fieldset class="content">
- <label for="description">Update Adventure Description:</label><br />
- <div class="ginput_container"><textarea id="description" cols="50" rows="10" tabindex="15" name="description"><?php echo $post_to_edit->post_content; ?></textarea></div> <!-- TEXT AREA OF CONTENT. NOTHING TO CHANGE -->
- </fieldset>
- <!-- images -->
- <!--<?php echo get_the_post_thumbnail( $post_to_edit->ID, array( 200, 150 ) ); ?><br /> <!-- WILL DISPLAY THE POST'S THUMBNAIL. YOU CAN CHANGE THE SIZE OF IT -->
- <!--<input type="checkbox" name="c1" onclick="showMe('image', this)" > <!-- SCRIPT CHECK IF CHANGING IMAGE OR NOT. NOTHING TO CHANGE -->
- <!--<fieldset id="image">
- <label for="image">Choose Image:</label>
- <input type="file" name="image" id="image" tabindex="30" value="" />
- </fieldset>-->
- <h3>Update Map Coordinates</h3>
- <!-- BELOW ARE THE CUSTOM FIELDS. CHANGE THEM ADD OR REMOVE -->
- <fieldset class="woo_maps_lat">
- <label for="woo_maps_lat">Change Latitude:</label><br />
- <input type="text" value="<?php echo get_post_meta($post_to_edit->ID,'woo_maps_lat', true); ?>" id="woo_maps_lat" tabindex="20" name="woo_maps_lat" /> <!-- Map Latitude -->
- </fieldset>
- <fieldset class="woo_maps_long">
- <label for="woo_maps_long">Change Longitude:</label><br />
- <input type="text" value="<?php echo get_post_meta($post_to_edit->ID,'woo_maps_long', true); ?>" id="woo_maps_long" tabindex="21" name="woo_maps_long" /> <!-- Map Longitude -->
- </fieldset>
- <h3>Update Adventure Details</h3>
- <fieldset class="skill_levels">
- <label for="skill_levels">Minimum Skill Level:</label><br />
- <div class="ginput_container"><select tabindex="22" class="medium gfield_select" id="input_3_8" name="input_8"><option value="<?php echo get_post_meta($post_to_edit->ID,'skill_levels', true); ?>"><?php echo get_post_meta($post_to_edit->ID,'skill_levels', true); ?></option><option value="Expert">Expert</option><option value="Advanced">Advanced</option><option value="Intermediate">Intermediate</option><option value="Novice">Novice</option></select></div>
- </fieldset>
- <fieldset class="gear_provided">
- <label for="gear_provided">Update Gear Provided:</label><br />
- <div class="ginput_container"><textarea id="gear_provided" cols="50" rows="10" tabindex="23" name="gear_provided"><?php echo get_post_meta($post_to_edit->ID,'gear_provided', true); ?></textarea></div> <!-- Gear Provided -->
- </fieldset>
- <fieldset class="gear_required">
- <label for="gear_required">Update Gear Required:</label><br />
- <div class="ginput_container"><textarea id="gear_required" cols="50" rows="10" tabindex="24" name="gear_required"><?php echo get_post_meta($post_to_edit->ID,'gear_required', true); ?></textarea></div> <!-- Gear Required -->
- </fieldset>
- <fieldset class="food_beverage">
- <label for="food_beverage">Update Food/Beverages Provided:</label><br />
- <div class="ginput_container"><textarea id="food_beverage" cols="50" rows="10" tabindex="25" name="food_beverage"><?php echo get_post_meta($post_to_edit->ID,'food_beverage', true); ?></textarea></div> <!-- Gear Required -->
- </fieldset>
- <fieldset class="transportation_provided">
- <label for="transportation_provided">Update Transportation Provided:</label><br />
- <div class="ginput_container"><textarea id="transportation_provided" cols="50" rows="10" tabindex="25" name="transportation_provided"><?php echo get_post_meta($post_to_edit->ID,'transportation_provided', true); ?></textarea></div> <!-- Gear Required -->
- </fieldset>
- <fieldset class="submit">
- <input type="submit" value="Update Adventure" class="button gform_button" tabindex="40" id="submit" name="submit" /> <!-- SUBMIT BUTTON -->
- </fieldset>
- <input type="hidden" name="postid" value="<?php echo $post_to_edit->ID; ?>" /> <!-- DONT REMOVE OR CHANGE -->
- <input type="hidden" name="action" value="edit_post" /> <!-- DONT REMOVE OR CHANGE -->
- <?php // wp_nonce_field( 'new-post' ); ?>
- </form>
- <!-- END OF FORM -->
- </div><!-- post -->
- </div><!-- main-single -->
- <?php get_sidebar(); ?>
- </div><!-- #content -->
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement