Tuesday, October 11, 2022
HomeWordPress DevelopmentMigrate Wordpress Customers to Appwrite

Migrate WordPress Customers to Appwrite


In Appwrite 1.0, a brand new characteristic has been added emigrate customers from different platforms like Firebase, WordPress, Supabase and so on. So on this tutorial we’re going to migrate all of the customers from WordPress to Appwrite and that is going to be tremendous simple!

Let’s do it 🦾



Step 1: Login to your WordPress web site and set up plugin

Firstly login to your WordPress web site’s admin panel and set up the free plugin named Import and export customers and clients

Import and export users and customers



Step 2: Export customers from WordPress

Now in your WordPress dashboard go to Instruments>Export>Customers (in CSV format) after which Obtain Export File

Wordpress export

Then obtain the csv file in line with your most well-liked settings

Export Users



Step 3: Import Customers to Appwrite

To import customers into Appwrite, we will use any Server SDK to entry the Customers API. For this instance, we’ll use the NodeJS SDK.

Newly added features allow you to create a consumer with one in every of 7 totally different hashing algorithms. WordPress makes use of PHPass Password. So we’ll use PHPass Password in Appwrite Server SDK to import customers.

async createPHPassUser(
        userId,
        e-mail,
        password,
        identify
      );
Enter fullscreen mode

Exit fullscreen mode

Going via the operate parameters one after the other:

  • userId: The ID to assign to the brand new consumer in Appwrite. It may be customized, or you should use the SDK’s new ID.distinctive() operate to assign a randomly generated ID.
  • e-mail: Corresponds to the e-mail worth from the csv file.
  • password: Corresponds to the passwordHash worth from csv file.
  • identify: The identify to assign to the consumer. Will be null.

Placing this all collectively, we may import all the exported customers into Appwrite like so:

const userslist = await CSVToJSON().fromFile("customers.csv");
  await Promise.all(
    userslist.map(async (consumer) => {
      await customers.createPHPassUser(
        ID.distinctive(),
        consumer.user_email,
        consumer.user_pass,
        consumer.display_name
      );
    })
  );
Enter fullscreen mode

Exit fullscreen mode

moreover it’s essential set up csvtojson bundle to parse CSV knowledge utilizing the command under

npm i csvtojson
Enter fullscreen mode

Exit fullscreen mode

After all of the consumer export the Appwrite dashboard seems to be like this

Appwrite Users

So now the entire code seems to be like this

const sdk = require("node-appwrite");
const { ID } = require("node-appwrite");
const CSVToJSON = require("csvtojson");

let consumer = new sdk.Shopper();

const customers = new sdk.Customers(consumer);

consumer
  .setEndpoint("Your Api Endpoint")
  .setProject("Your Venture Key")
  .setKey("Your Api Key")
  .setSelfSigned();

const migrate = async () => {
  const userslist = await CSVToJSON().fromFile("customers.csv");
  await Promise.all(
    userslist.map(async (consumer) => {
      await customers.createPHPassUser(
        ID.distinctive(),
        consumer.user_email,
        consumer.user_pass,
        consumer.display_name
      );
    })
  );
};

migrate()
  .then((r) => console.log("Carried out!"))
  .catch((e) => console.log(e));

Enter fullscreen mode

Exit fullscreen mode

Hope you learn to migrate customers from WordPress to Appwrite.
Remember to observe me @joysankar2001

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments