我有一个由 WordPress 提供支持的网站。我通过使用一些插件(联系表格 7、联系表格 7 多步骤表格和高级 CF7 DB)来实现会员注册表格。提交表单时,我想在此表单中添加一个功能。为此,我决定使用上述插件'contact form 7'实现的动作挂钩'wpcf7_before_send_mail',就像functions.php中的以下代码一样。
function sample_func($contact_form){
var_dump($contact_form);
};
add_action( 'wpcf7_mail_sent', 'sample_func', 20, 1 );
然后,我收到以下错误消息。(此消息是在 MAMP 上的相同情况下生成的。)
Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/wp-workshop/wp-content/themes/twentytwentyone/functions.php:677) in /Applications/MAMP/htdocs/wp-workshop/wp-includes/rest-api/class-wp-rest-server.php on line 1642
[06-Apr-2021 14:04:03 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/wp-workshop/wp-content/themes/twentytwentyone/functions.php:677) in /Applications/MAMP/htdocs/wp-workshop/wp-includes/rest-api.php on line 675
[06-Apr-2021 14:04:03 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/wp-workshop/wp-content/themes/twentytwentyone/functions.php:677) in /Applications/MAMP/htdocs/wp-workshop/wp-includes/rest-api.php on line 676
[06-Apr-2021 14:04:03 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/wp-workshop/wp-content/themes/twentytwentyone/functions.php:677) in /Applications/MAMP/htdocs/wp-workshop/wp-includes/rest-api.php on line 677
[06-Apr-2021 14:04:03 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/wp-workshop/wp-content/themes/twentytwentyone/functions.php:677) in /Applications/MAMP/htdocs/wp-workshop/wp-includes/rest-api.php on line 678
是什么导致了这个问题?先感谢您。