parse membership 2 code

i am trying to implement some code to your memberpreship site 2 plugin, i want to read if a user which enter an username and password is a a membership premium user.

so i make a query to the database and got this code:

a:1:{i:0;O:21:"MS_Model_Relationship":28:{s:16:"*membership_id";s:4:"7213";s:13:"*gateway_id";s:14:"paypalstandard";s:13:"*start_date";s:10:"2017-1
1-15";s:14:"*expire_date";s:10:"2017-12-15";s:20:"*trial_expire_date";s:0:"";s:25:"*trial_period_completed";s:1:"1";s:9:"*status";s:8:"canceled";s:
25:"*current_invoice_number";i:1;s:15:"*move_from_id";s:1:"0";s:24:"*cancelled_memberships";s:0:"";s:9:"*source";s:0:"";s:12:"*source_id";s:0:"";s:
11:"*payments";a:1:{i:0;a:4:{s:4:"date";s:16:"2017-11-15 16:25";s:6:"amount";d:10;s:7:"gateway";s:14:"paypalstandard";s:11:"external_id";s:17:"9LS2
6155DP2693244";}}s:15:"*is_simulated";s:0:"";s:15:"*payment_type";s:9:"recurring";s:12:"*email_log";a:0:{}s:33:"MS_Model_Relationshipmembership";O:
19:"MS_Model_Membership":28:{s:5:"*id";i:7213;s:7:"*name";s:7:"premium";s:8:"*title";s:0:"";s:14:"*description";s:0:"";s:14:"*rule_values";a:1:{s:4
:"page";a:1:{i:0;i:7909;}}s:7:"*type";s:6:"simple";s:15:"*payment_type";s:9:"recurring";s:9:"*active";s:1:"1";s:10:"*private";s:0:"";s:10:"*is_free
";s:0:"";s:20:"*disabled_gateways";a:0:{}s:8:"*price";s:2:"10";s:9:"*period";a:2:{s:11:"period_unit";i:1;s:11:"period_type";s:4:"days";}s:19:"*pay_
cycle_period";a:2:{s:11:"period_unit";i:1;s:11:"period_type";s:6:"months";}s:24:"*pay_cycle_repetitions";s:1:"0";s:20:"*period_date_start";s:0:"";s
:18:"*period_date_end";s:0:"";s:23:"*trial_period_enabled";s:0:"";s:14:"*trial_price";s:1:"0";s:15:"*trial_period";a:2:{s:11:"period_unit";i:1;s:11
:"period_type";s:4:"days";}s:23:"*on_end_membership_id";s:1:"0";s:21:"*is_setup_completed";s:0:"";s:9:"*source";s:0:"";s:12:"*source_id";s:0:"";s:1
4:"*custom_data";a:1:{s:13:"no_invitation";s:4:"true";}s:16:"*update_denied";a:0:{}s:17:"*update_replace";a:0:{}s:11:"*revision";s:1:"5";}s:46:"MS_
Model_Relationshiprecalculate_expire_date";b:1;s:5:"*id";i:31852;s:7:"*name";s:33:"user_id: 141, membership_id: 7213";s:8:"*title";s:0:"";s:14:"*de
scription";s:33:"user_id: 141, membership_id: 7213";s:10:"*user_id";s:3:"141";s:16:"*post_modified";s:19:"2017-12-16 21:02:10";s:14:"*custom_data";
a:0:{}s:9:"_in_cache";b:1;s:11:"_saved_data";a:22:{s:13:"membership_id";s:4:"7213";s:10:"gateway_id";s:14:"paypalstandard";s:10:"start_date";s:10:"
2017-11-15";s:11:"expire_date";s:10:"2017-12-15";s:17:"trial_expire_date";s:0:"";s:22:"trial_period_completed";s:1:"1";s:6:"status";s:8:"canceled";
s:12:"move_from_id";s:1:"0";s:21:"cancelled_memberships";s:0:"";s:6:"source";s:0:"";s:9:"source_id";s:0:"";s:8:"payments";a:1:{i:0;a:4:{s:4:"date";
s:16:"2017-11-15 16:25";s:6:"amount";d:10;s:7:"gateway";s:14:"paypalstandard";s:11:"external_id";s:17:"9LS26155DP2693244";}}s:12:"is_simulated";s:0
:"";s:12:"payment_type";s:9:"recurring";s:9:"email_log";a:0:{}s:2:"id";i:31852;s:4:"name";s:33:"user_id: 141, membership_id: 7213";s:5:"title";s:0:
"";s:11:"description";s:33:"user_id: 141, membership_id: 7213";s:7:"user_id";s:3:"141";s:13:"post_modified";s:19:"2017-12-16 21:02:10";s:11:"custom
_data";a:0:{}}s:14:"*_factory_id";s:41:"

My problems is that i want to access to the place where 7213 is written to evaluate if the user belongs to the premium membership site. this code is json like.

i want to make it a integration using nodejs.

  • Paul Kevin

    Hey there Pablo ,

    Hope you are well today and thank you for your patience on this matter. For the data you have extracted, you will need to convert it to the string data to Javascript using a package like https://github.com/naholyr/js-php-unserialize . Alternatively with SQL you can run a query like this
    select u.ID, u.user_email, u.user_nicename, s.post_title as 'Membership', substring_index(substring_index(m.post_content,',',-1),':',-1) as 'Membership ID' from wp_users u LEFT JOIN wp_posts m ON( substring_index(substring_index(m.post_content,',',1),':',-1) = u.ID ) LEFT JOIN wp_posts s ON(s.ID = substring_index(substring_index(m.post_content,',',-1),':',-1)) LEFT JOIN wp_posts r ON(u.ID = substring_index(substring_index(r.post_content,',',1),':',-1)) LEFT JOIN wp_postmeta rm ON(rm.post_id = r.ID) WHERE substring_index(substring_index(r.post_content,',',-1),':',-1) = substring_index(substring_index(m.post_content,',',-1),':',-1) AND rm.meta_key = "status" AND rm.meta_value = "active" AND u.ID = ?;
    Where the ? at the end is replaced with the user id.

    Warm Regards
    Paul Kevin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.