WPForm 使用 PHP 取得各種資訊的方法

取得特定 Form 資料

$form_id = 17385;
$form = wpforms()->form->get($form_id);
$form_data = json_decode($form->post_content, true);

$webhook = $form_data['settings']['webhooks'][1];
$webhook = new Webhook( $webhook );
$webhook_data = $webhook->get_data();

取得特定 Entry 資料

$entry_id = 8259;
$entry = wpforms()->entry->get($entry_id);
$form_data = json_decode($entry->fields, true);

取得特定區間的 Entry 資料

args = [
    'date' => [
        '2024-10-10 00:00:00',
        '2024-11-15 23:59:59'
    ]
];

// Get all entries matching the date range
$entries = wpforms()->entry->get_entries($args);

// Loop through entries if needed
foreach ($entries as $entry) {
    // Access entry data
    $entry_id = $entry->entry_id;
    $form_id = $entry->form_id;
    $fields = json_decode($entry->fields, true);
    // ... work with entry data
}