2015-06-18 92 views
0

使用PHP頭功能工作頁面重定向在WordPress插件米頭功能在WordPress插件

我的代碼是

$URL = admin_url('admin.php?page=myaccount&success=yes'); 
header("location:".$URL); 
exit(); 

它給我的錯誤是這樣的。

警告:不能更改頭信息 - 已經 發送的報頭 (輸出開始 /home/fusionmark/public_html/wp/wp-admin/includes/template.php:1877) /家/ fusionmark /的public_html/WP /可溼性粉劑內容/插件/ JVZoo/includes.php 上線258

+0

你爲什麼使用這個重定向? – sarath

+0

我需要重定向頁面 –

+0

可能的重複[如何解決]已經發送的頭文件「PHP中的錯誤」(http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error- in-php) – Achrome

回答

0

使用wp_safe_redirect()函數

$redirect = admin_url('admin.php?page=myaccount&success=yes'); 
wp_safe_redirect($redirect); 
die(); 
+0

警告:無法修改標頭信息 -/home/fusionmark/public_html/wp /中已經發送的標頭(輸出開始於/home/fusionmark/public_html/wp/wp-admin/includes/template.php:1877) wp-includes/pluggable.php 1178行 –

+0

我能知道爲什麼要使用這個重定向嗎?在執行某些操作後將此代碼 – sarath

+0

放在哪裏,我想將頁面重定向到儀表板 –

0
$URL = admin_url('admin.php?page=myaccount&success=yes'); 
header("location:".$URL); 
exit(); 

,而不是使用:

$location = admin_url('admin.php?page=myaccount&success=yes'); 
wp_redirect($location); 
exit; 

任何重定向鉤就可以使用,但它get_header之前將();