Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: sherpa edit guide
- */
- ?>
- <?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']; // Guide Profile Name
- $description = $_POST['description']; // Guide Bio
- $latitude = $_POST['woo_maps_lat']; // Latitude custom field for updating map
- $longitude = $_POST['woo-maps_long']; // Longitude custom field for updating map
- $experience = $_POST['guide_experience_level']; // Update experience level
- $training = $_POST['training_certification']; // Update certifications
- $languages = $_POST['languages']; // Update languages
- $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, 'guide_experience_level', $experience); // Guide Experience
- update_post_meta($pid, 'training_certification', $training); // Guide Training & Certifications
- update_post_meta($pid, 'languages', $languages); // Guide Languages
- //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 Guide Profile 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 Bio:</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>
- <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">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">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 Profile Details</h3>
- <fieldset class="guide_experience_level">
- <label for="guide_experience_level">Update Experience:</label><br />
- <input type="text" value="<?php echo get_post_meta($post_to_edit->ID,'guide_experience_level', true); ?>" id="guide_experience_level" tabindex="22" name="guide_experience_level" /> <!-- Guide Experience -->
- </fieldset>
- <fieldset class="training_certification">
- <label for="training_certification">Update Certifications & Training:</label><br />
- <div class="ginput_container"><textarea id="training_certification" cols="50" rows="10" tabindex="23" name="training_certification"><?php echo get_post_meta($post_to_edit->ID,'training_certification', true); ?></textarea></div> <!-- Guide Certifications & Training -->
- </fieldset>
- <fieldset class="languages">
- <label for="languages">Update Languages:</label><br />
- <div class="ginput_container"><textarea id="languages" cols="50" rows="10" tabindex="24" name="languages"><?php echo get_post_meta($post_to_edit->ID,'languages', true); ?></textarea></div> <!-- Guide Languages -->
- </fieldset>
- <fieldset class="submit">
- <input type="submit" value="Update Profile" 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 -->
- <input type='hidden' name='redirect_to' id='redirect_to' value='http://sherpademo.co.cc/guide-portal/' />
- <?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