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

时间:2018-05-07 07:31:15

标签: wordpress subscription jetpack

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

1 个答案:

答案 0 :(得分:0)

找到了答案here,并将其加入here的另一个答案:

Jetpack subscriptions未托管在您的网站上,而是托管在WordPress.com服务器上。因此,您无法直接添加到数据库中。

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

<?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);
}