WordPress - 从 *.csv 文件导入电子邮件订阅

WordPress - import email subscriptions from *.csv file

我们如何将 Jetpack subscriptions 的电子邮件地址从 CSV 文件导入到 WP

已找到答案here and joined it with another answer from here:

Jetpack subscriptions 未托管在您的站点上,它们托管在 WordPress.com 服务器上。所以不能直接添加到数据库中。

但是,如果您查看 Jetpack 插件代码,它会概述用于与 WordPress.com 交互和添加订阅者的 XML-RPC 调用。所以你可以建立自己的进口商...

<?php
//1. the "file_name_here.csv" should get changed to your need
//2. the script just needs to get placed on site like "example.com/subscribe.php"
//3. just execute it in the browser using your link

require_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');

$row = 1;
if (($handle = fopen("file_name_here.csv", "r")) !== FALSE) {
  while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $num = count($data);
    echo "<p> $num fields in line $row: <br /></p>\n";
    $row++;
    for ($c=0; $c < $num; $c++) {
        $email = $data[$c];
        echo $email . "<br />\n";
        Jetpack_Subscriptions::subscribe( $email );
    }
  }
  fclose($handle);
}