レコードを挿入して取得するためのプラグインを作成しました。レコードを保存すると、レコードはローカルホストから保存されていますが、オンラインサーバーで試してみると保存されません。ここに私がやろうとしていることがあります。Wordpressのプラグインデータがカスタムテーブルに挿入されていません
function data_custom_ajax(){
global $wpdb;
$tbl = "tripplan";
$table_name=$wpdb->prefix . $tbl;
$custom_val = $_POST['text'];
$totaltime = $_COOKIE['totalduration'];
$totaldistance = $_COOKIE['totaldistance'];
$origin_address = $custom_val['originaddress'];
$end_address = $custom_val['destinationaddress'];
$waypoints = $custom_val['waypts'];
$wpdb->insert($table_name,
array(
'startpoint' => $origin_address,
'endpoint' => $end_address,
'waypoints' => json_encode($waypoints),
'totaldistance' => $totaldistance,
'totalduration' => $totaltime
),
array('%s','%s','%s','%f','%f')
);
echo "data has been saved";
}
あなたはこの関数を呼び出していますか? –
私はログインしたユーザのためにそれを追加しました。ログインしていないユーザは 'add_action( 'wp_ajax_data_custom_ajax'、 'data_custom_ajax'); add_action( 'wp_ajax_nopriv_data_custom_ajax'、 'data_custom_ajax'); ' –
はあなたのために働いていますか? –