After using a function to submit custom fields the standard redirection is not longer working. What we would like is that after the post has been insetered for the user to be redirected the standard wp_redirect is not at the moment working. I theorise this is because of the custom fields submission function.
The code
if ( is_user_logged_in() ) {
$my_post = array(
'post_title' => $_SESSION['booking-form-title'],
'post_date' => $_SESSION['cal_startdate'],
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_type' => 'booking',
'post_author' => $user_ID,
);
$the_post_id = wp_insert_post( $my_post );
__update_post_meta( $the_post_id, 'duration', $_SESSION['booking-form-actual-duration'] );
__update_post_meta( $the_post_id, 'picture', $_SESSION['booking-form-picture'] );
__update_post_meta( $the_post_id, 'totalprice', $_SESSION['booking-form-total-price'] );
__update_post_meta( $the_post_id, 'activityduration', $_SESSION['booking-form-total-duration'] );
__update_post_meta( $the_post_id, 'totaldives', $_SESSION['booking-form-total-dives'] );
query_posts('post_type=services'); while (have_posts()) : the_post();
__update_post_meta( $the_post_id, 'producttitle'.get_the_ID(), $_SESSION['products-form-title'.get_the_ID()]);
__update_post_meta( $the_post_id, 'productprice'.get_the_ID(), $_SESSION['products-form-price'.get_the_ID()]);
__update_post_meta( $the_post_id, 'productduration'.get_the_ID(), $_SESSION['products-form-duration'.get_the_ID()]);
__update_post_meta( $the_post_id, 'productdives'.get_the_ID(), $_SESSION['products-form-dives'.get_the_ID()]);
__update_post_meta( $the_post_id, 'productquantity'.get_the_ID(), $_SESSION['products-form-quantity'.get_the_ID()]);
endwhile;
$linkit = get_permalink($the_post_id);
wp_redirect($linkit);
}
else {;}
the wp_redirect is producing the following error Warning: Cannot modify header information - headers already sent by (output started at /home/divethe1/public_html/update/wp-content/themes/master/type-booking.php:18) in /home/divethe1/public_html/update/wp-includes/pluggable.php on line 890
Just so we are on the same page to change $the_post_id to $post_id negated the function and still does not perform the redirect. The function and procedure to make it can be found at WP insert post PHP function and Custom Fields
The objective is therefore to redirect the user to the page created by the wp_insert_post. If anyone can see where I have gone wrong, many thanks,
Marvellous