Closed shgysk8zer0 closed 8 years ago
There is an add-on for the plugin to import users. Looking into using that. Requires creating a CSV.
Update: The plugin only imports regular users. To import as members requires a
Paid Memberships Pro - Import Users from CSV Add On
Code for creating new users seems to be
$wpdb->prepare("
INSERT INTO {$wpdb->pmpro_memberships_users}
( `user_id`, `membership_id`, `code_id`, `initial_payment`, `billing_amount`, `cycle_number`, `cycle_period`, `billing_limit`, `trial_amount`, `trial_limit`, `startdate`, `enddate`)
VALUES
( %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %s, %s )",
$user_id,
$level_id,
'0',
'0',
'0',
'0',
'0',
'0',
'0',
'0',
current_time('mysql'),
'0000-00-00 00:00:00'
);
Update query seems to be
$wpdb->prepare("
INSERT INTO {$wpdb->pmpro_memberships_users}
(`user_id`, `membership_id`, `code_id`, `initial_payment`, `billing_amount`, `cycle_number`, `cycle_period`, `billing_limit`, `trial_amount`, `trial_limit`, `startdate`, `enddate`)
VALUES
( %d, %d, %d, %s, %s, %d, %s, %d, %s, %d, %s, %s )",
$level['user_id'], // integer
$level['membership_id'], // integer
$level['code_id'], // integer
$level['initial_payment'], // float (string)
$level['billing_amount'], // float (string)
$level['cycle_number'], // integer
$level['cycle_period'], // string (enum)
$level['billing_limit'], // integer
$level['trial_amount'], // float (string)
$level['trial_limit'], // integer
$level['startdate'], // string (date)
$level['enddate'] // string (date)
);
Trying to update all users using UPDATE wp_pmpro_memberships_users SET membership_id = 5 WHERE membership_id > 7;
Write PHP function using prepared statement to update subscription status of registered users.
Update subscribers in WordPress
wp_users
MariaDB [kernvalleysun]> DESCRIBE wp_users;
wp_usermeta
MariaDB [kernvalleysun]> DESCRIBE wp_usermeta;
wp_pmpro_memberships_users
MariaDB [kernvalleysun]> DESCRIBE wp_pmpro_memberships_users;
15 rows in set (0.00 sec)
User meta
MariaDB [kernvalleysun]> SELECT DISTINCT(meta_key) FROM wp_usermeta;
43 rows in set (0.00 sec)
user_capabilities
MariaDB [kernvalleysun]> SELECT DISTINCT(meta_value) FROM wp_usermeta WHERE meta_key = 'wp_capabilities';
4 rows in set (0.00 sec)
WP PMPRO Membership Status
MariaDB [kernvalleysun]> SELECT DISTINCT status FROM wp_pmpro_memberships_users;
2 rows in set (0.00 sec)