• Resolved tpo

    (@topod)


    Hi!

    I need some advice. I have a file (in .csv, .xml, .xls format) with data about members (email, first name, last name), about membership (membership type) and about membership start and expiration dates (respectively some records are with lifetime access and some with recurring subscription).

    How do I import this data into the database? I tried it via WP All Import, but I was only able to import members without membership.

    I was looking at the SQL database to see how it’s handled there and I found that you have one database for members and the other one for memberships / payments. Is there any way to import it there in bulk, e.g. via an SQL statement?

    The bulk listed here: https://www.cozmoslabs.com/docs/paid-member-subscriptions/member-management/#Bulk_Add_New_Member doesn’t help me because each of the members can have different expiration dates, plus you can’t set a recurrence in this bulk (unless someone has purchased a recurring membership).

    It would probably help me the most if you could write me which SQL statement writes the new membership to the database (both the classic one and the one that is recurring). I would be able to link this to my file and bulk import the members.

    If you have a better idea, I’m open to it.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support madalinaruzsa

    (@madalinaruzsa)

    Hi @topod,

    Do you want to import data from a site with Paid Member Subscriptions plugin to another site with Paid Member Subscriptions plugin? Or are you using another plugin on the old site?

    Thread Starter tpo

    (@topod)

    Hi madalinaruzsa!

    No, the problem is that I need to move users from a site that wasn’t made in WordPress and I only have the data for the users that I’ve listed above in the file.

    Thanks!

    Plugin Support madalinaruzsa

    (@madalinaruzsa)

    Hi @topod,

    Unfortunately, importing/exporting subscriptions is not currently possible with our plugin, but I have added your request to our development list, so it might be implemented in a future version, but we can’t estimate when that may be.

    Note 1: A workaround would be to export the user from the old site to the new site -> then the user will need to log into their account -> after which they can go to the Register page from where they can subscribe to a subscription plan.

    Note 2: Or another workaround would be to export the user from the old site to the new site -> and as an admin from the WordPress Dashboard -> Paid Member Subscriptions -> Members page -> you can assign subscription plans to the users. You can read more about this here: https://www.cozmoslabs.com/docs/paid-member-subscriptions/member-management/#Add_New_Member

    Note 3: Or you can modify the database. The databases that you need to import are wp_pms_member_subscriptionmeta, wp_pms_member_subscriptions, wp_pms_paymentmeta, wp_pms_payments. But it is rather a complex job so if you are not used to working with databases my advice would be to ask for a developer’s help.

    Thread Starter tpo

    (@topod)

    Hi madalinaruzsa,

    thank you very much for your comprehensive reply!

    I understand that this can’t be imported directly through your plugin, and I also understand that because you can’t address all the different scenarios. It’s understandable, that’s why I’m trying to find another way.

    To your notes:
    ad 1/ The big negative in this proposal is that some users in the original database has a paid membership until some date in the future. By importing only name and password without membership, such users would lose their already paid membership.

    ad 2/ This is something I would need, but the current solution is very cumbersome because there is only one user to set up in one step. If I have several hundred of those users, it would take an inefficiently long time. But I could imagine something like this being set up via a workaround in SQL statements in classic PHP. I would define there in arrays the data about the users that I have from the original site (username, email address, membership start date, membership end date, membership type) and then through some simple foreach would start adding to the database via SQL statements. All I need for this is a description of the SQL commands that are used to add memberships via this tool: https://www.cozmoslabs.com/docs/paid-member-subscriptions/member-management/#Add_New_Member so that I can add them to that foreach. I guess my idea would be that I would first import users with data via WP All Import, and then add membership information to those users via the aforementioned foreach. This could be paired either by email or by username. In a nutshell it would look something like this (just a very rough sketch):

    <?php
    /* array: email, date_from, date_to, membership_level */
        $memberships = array (
    array("[email protected]","2023-10-20","2024-10-20","gold_membership"),
    array("[email protected]","2023-10-25","2024-10-25","silver_membership"),
    ...... ((( and so on )))
    );
    
    ((( here will be a script that I will create that will pair the emails from the previous array with the user ID numbers from the "wp_users" table for the purposes of the "user_id" column in the "wp_pms_member_subscriptions" table )))
    
    foreach () {
        INSERT INTO ...... ((( here will be the SQL statements which will insert the membership details into the database )))
    }
    ?>

    Thank you very much for the reply!

    A.

    Plugin Author Georgian Cocora

    (@raster02)

    Hello @topod,

    I don’t have any specific SQL commands to share, you simply need to look at the database table with subscriptions *_pms_member_subscriptions and follow the structure. Not all the columns are necessary, you only need basic ones like: user_id, subscription_plan_id, start_date, expiration_date, status

    I would suggest you to add a subscription manually through the interface and then look at the row that is added in the table I mentioned. You need to do the same thing.

    Users are linked with their user_id so you need to have that in your data instead of email.

    Regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Bulk Import Members from file’ is closed to new replies.