Get record of current subscriber

  • Hilmar Schneider
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 8 months ago #152965 by Hilmar Schneider
Get record of current subscriber was created by Hilmar Schneider
How do I get the subscriber record of the currently signed in person? I can use JFactory::getUser() to get the Joomla user record but I also need some subscriber date (like the membership id).

I found getSubscriptionDate($id) but I don't know the id of the current user.

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #152970 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Get record of current subscriber
Hello Hilmar

In Membership Pro, one user could have subscription records of different subscription plans. So in this case, what record you want to get?

Tuan

Please Log in or Create an account to join the conversation.

  • Hilmar Schneider
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 8 months ago - 1 year 8 months ago #153009 by Hilmar Schneider
Replied by Hilmar Schneider on topic Get record of current subscriber
In my case we have two plans (Individual and Lifetime) and a subscriber belongs to one or the other. I looked at the db (using phpMyAdmin) and there is a table osmembership_subscribers that contains subscription records. I didn't see a table for subscribers.

I guess I would need a query along the lines of:
SELECT * FROM osmembership_subscribers
WHERE (username = JFactory::getUser()) AND published;

I would then need to step through the record set to collect the information I need. In theory all the subscription records for a given username should have the same membership_id.
Last edit: 1 year 8 months ago by Hilmar Schneider.

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #153011 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Get record of current subscriber
Hello

Try the following code to see if it works for your need:
Code:
require_once JPATH_ADMINISTRATOR . '/components/com_osmembership/loader.php'; $user = JFactory::getUser(); $item = OSMembershipHelperSubscription::getMembershipProfile($user->id);

Then $item variable will contains the subscription record. You can access to data like $item->first_name, $item->last_name, $item->plan_id,.....

Please try that and let me know if you have other questions

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Hilmar Schneider
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 8 months ago #153014 by Hilmar Schneider
Replied by Hilmar Schneider on topic Get record of current subscriber
Thanks, that worked great.

Hilmar

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #153015 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Get record of current subscriber
Great. Thanks for confirming

Tuan

Please Log in or Create an account to join the conversation.