2014-03-13 50 views
1

我正在寫一個Wordpress插件。有了這個插件,我更新了一些數據。查詢和更新工作正常,但我的標題("location: url");不起作用。如果我放置一個回聲,它不會給出頭部已經發送的任何錯誤。看起來它對這些行不做任何事。我的代碼...標題位置在我的wordpress插件中不起作用。

<?php require_once('../../../wp-config.php'); 
$baanstatus_table=$wpdb->prefix . 'baanstatus'; 
$id = $_GET['id']; 
$bijgewerkt =$_GET['bijgewerkt']; 
$baanstatus= $_GET['baanstatus']; 
$handicarts = $_GET['handicarts']; 
$trolleys = $_GET['trolleys']; 
$winterontheffing = $_GET['winterontheffing']; 
$zomergreens = $_GET['zomergreens']; 
$qualifying = $_GET['qualifying']; 
$onderhoud_greens = $_GET['onderhoud_greens']; 
$onderhoud_anders = $_GET['onderhoud_anders']; 
$opmerkingen = $_GET['opmerkingen']; 
global $wpdb; 
$data_array =array('id' => $id, 
'bijgewerkt' => $bijgewerkt, 
'baanstatus' => $baanstatus, 
'handicarts' => $handicarts, 
'trolleys' => $trolleys, 
'winterontheffing' =>$winterontheffing, 
'zomergreens' =>$zomergreens, 
'qualifying' =>$qualifying, 
'onderhoud_greens' =>$onderhoud_greens, 
'onderhoud_anders' =>$onderhoud_anders, 
'opmerkingen' =>$opmerkingen 
); 
$where =array('id' => $id); 
$wpdb->update($baanstatus_table, $data_array, $where); 
header("location:http://almeerderhout.fcklap.com/wp-admin/options-general.php?page=my-unique-identifier"); 
exit(); 
?> 

回答

1

下面的代碼將幫助您

<?php 
wp_redirect($location, $status); 
exit; 
?> 

以上WordPress的功能將使用重定向Codex Link function reference

+1

不工作....問題是,頭文件已經在我需要的文件中發送。警告:無法修改標頭信息 - 在/ home/almeer/domains /中已經發送的標頭(輸出開始於/home/almeer/domains/almeerderhout.nl/public_html/wp-content/plugins/baanstatus/index.php:86) almeerderhout.nl/public_html/wp-includes/pluggable.php在線896 – user3240923

+0

在word新聞主插件文件中避免了程序起始行和結束行的空閒空間。 https://codex.wordpress.org/Writing_a_Plugin請參閱鏈接。 –

2

也許你應該嘗試,而不是PHP位置的JavaScript。

<?php 
    echo '<script>location.href="http://almeerderhout.fcklap.com/wp-admin/options-general.php?page=my-unique-identifier";</script>'; 
?> 
相關問題