使用函数提交自定义字段后,标准重定向不再工作。我们希望的是,在插入帖子以重定向用户后,标准的wp\\U重定向目前不起作用。我推测这是因为自定义字段提交功能。
代码
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 {;}
wp\\U重定向产生以下错误
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
正因为如此,我们在同一页上将$the\\u post\\u id更改为$post\\u id否定了该函数,仍然不执行重定向。其功能和程序可在以下网址找到:WP insert post PHP function and Custom Fields
因此,目标是将用户重定向到由wp\\u insert\\u post创建的页面。如果有人能看到我错在哪里,非常感谢,
非凡的