API or Helper Functions or Direct to Database?

More
7 years 9 months ago #100675 by Steve
Hi,
We have recently moved our website & membership management for a sports organisation from a bespoke system into a Joomla and Membership Pro solution - which works great.
My problem is I need to integrate a remaining bespoke application that processes competition results. It needs to query membership details and on occasion create new member records in order to either find or create a membership ID for reuse as a key in some other tables.
I'm pretty sure Membership Pro doesn't currently have an inbound API and I couldn't find functions that I thought I could reuse, leaving direct access to the database.
I think a query on jm_osmembership_subscribers to find an existing member looks fairly straight forward but when creating a new one (with minimal data) are there any gotchas to worry about? or can you advise a better way to do this?

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

More
7 years 9 months ago #100679 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic API or Helper Functions or Direct to Database?
Hi Steve

Sadly, at the moment, we don't have that kind of API available:

1. To get list of subscription records of one user, Yes, query the database table #__osmembership_subscribers is the only way at the moment

2. To get list of active subscription plans which a user has, there is a helper method:

require_once JPATH_ROOT . '/components/com_osmembership/helper/helper.php';

$userId = 42;
$activePlans = OSMembershipHelper::getActiveMembershipPlans($userId);

3. For creating a new subscription, unfortunately, it is the hardest part. Maybe you can look at the code in administrator/components/com_osmembership/model/import.php, method store to see how we create a subscription record and use these kind of code to create subscription record

We should have an API for that, sorry. Something I will have support for in the future (might be the next release if I have enough time - in 3 - 4 weeks)

Tuan
The following user(s) said Thank You: Steve

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

More
7 years 9 months ago - 7 years 9 months ago #100680 by Steve
Thanks for the very fast support Tuan - much appreciated!
Sorry just one more question.
I'm a bit confused with some of the terminolgy arounf User, Member, Subscriber, Plan and Subscription:
Can a 'User' exist in jm_osmembership_subscribers and not have a 'subscription' or 'plan' as such?
For example, when I import our historical data we may have records for individuals who are no longer alive and may only have minimal details such as full name, date of birth, membership_id .
I gues in summary - what is the minimum data that needs to be captured to create a coherent 'User' record i.e one that won't break the system and could if wished be activated into a full subscriber with a plan via the front-end at a later date if needed?

S
Last edit: 7 years 9 months ago by Steve. Reason: forgot to add additional query

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

More
7 years 9 months ago #100711 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic API or Helper Functions or Direct to Database?
In short, you will need ;

1. Create a user account. That's a Joomla user. To have an account created, you need to pass data username, password, name, email. Note that ID of the user will be stored in user_id field of #__osmembership_subscribers table

2. Create a subscription record. That's the record of #__osmembership_subscribers table.

Then it should be fine

As I said, you can look at administrator/components/com_osmembership/model/import.php to see how we handle it

Regards,

Tuan

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