dongyi1015 2018-02-05 03:41
浏览 32


I am developing a plugin where user will submit a form. The form submits to the same page. Form data handling code is implemented by checking the condition-

if ( !empty( $_POST['action'] ) && $_POST['action'] == 'customer_add_new')

Then the data is validated and entered to database using $wpdb->insert.

After that, I want to pass a variable to the URL, so that success message can be displayed and user can be stopped from re-submitting the form by refreshing the page. For that, I used-

$url = add_query_arg( array(
    'customer_add_new' => 'success'
    ) );
wp_redirect( $url );

But this code is throwing the following error-

Warning: Cannot modify header information - headers already sent by (output started at E:\wamp\www\cp_plugin\wp-includes\class.wp-scripts.php:343) in E:\wamp\www\cp_plugin\wp-includes\pluggable.php on line 1216

I have successfully used the same code in the theme for this very same project. But the functionality was better suited for a plugin, than for a theme.

  • 写回答

1条回答 默认 最新


      相关推荐 更多相似问题


      • ¥25 接口/特征方法的异常错误返回如何判断是否需要设计
      • ¥40 代码+预测分析,文件私信发哦(价格可商量)
      • ¥15 GAMES101 HW1 无法定义
      • ¥15 pycharm不管允许什么代码都出错,都会出现下面的情况。
      • ¥15 boost::integrate的用法
      • ¥20 51单片机输出pwm时无法调节频率,如何解决?
      • ¥15 DSP28335 AD采集正弦波
      • ¥50 pwwinauto调式修改
      • ¥30 关于#单片机#的问题:单片机基于51单片机开发计时器,使其实现以下功能:(1)开发板上四个独立按键分别控制计时器的启停、计时器的复位(按下计时值归零)、计时位切换、计时时间的递增
      • ¥15 看个代码。做个详细的解说