Skip Navigation

[Resolved] allow users to purchase several courses on a membership site

This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by Ido Angel 7 years ago.

Assisted by: Christian Cox.

Author
Posts
#586479

hey,
i am working in the last weeks on a membership site for video courses.
i have (almost) everything up and running (there's still one issue open but in another thread).
i am charging users with a cred commerce user form for viewing courses. but the thing is, a user who purchased a course can only view this one specific course. what happens if he want to purchase another course? the cred commerce form creates a new user, not adding a new role for an existing one.
is this even possible? i have downloaded and installed the "multiple roles" wp plugin. and i guess i can block the cred commerce form of a specific course to everyone but guests, and for others i can display another layout with a "edit user" instead of "add new user" form.
but:

1) this is tiring. to have to create 2 forms for each course, change each form's access, etc
2) i'm not even sure editing a new user will really just add a new role instead of change the current one

is there a simple way to go about this?

thanks!

#586879

Toolset and CRED are not designed to work with multiple roles, so I think a Toolset-based way would be to use a custom field on the User's profile to store a list of purchased Course IDs. It will take a bit more effort to set up in the beginning, but then it will be automated and fairly hands-off. In general it would work like this:
- You need two CRED forms only: one to Register / Purchase a Course (create new User) and one to purchase additional Courses (add a new Tracking post, see below).
- You need an additional post type that will be hidden from the front-end of the site. We can call this "Purchase Tracker". It will be used to allow Users to purchase additional courses, and perform actions on the User's profile when the purchase is complete in WooCommerce. This is required because it's not currently possible to capture the Course ID in an edit User CRED form and use that value to update the User's profile when the Order is completed in WC. That type of manipulation is only possible in a new or edit post CRED form.
- Guests are shown the new User CRED Commerce form on a Course page, or in a View of Courses, or on a page with a Course ID URL parameter (yoursite.com/register?course=12345). The Guest submits the form to purchase the Membership Product and when payment is complete, a User is created and a reference to the Product is stored in a custom field in their profile. This custom field will be set up to store multiple values, so you can add / remove Course IDs as needed. See below.
- Once a User has become a paid Member, you can show them the 2nd CRED Commerce form - create a new "Purchase Tracker" post - on Course pages they have not purchased. This form will include a button to "Purchase Course", or something similar, and will include a hidden field that contains the Course ID of this Course. Nothing else will be shown in this form. When the button is pressed, the form will submit and they will be redirected to the Checkout page as before with the Course Product.
- Using the CRED API again, you will trigger some custom code once the order is completed. This code will find the relevant Course ID from the related Purchase Tracker post, and append that value to the User's repeating custom field. I can help you with this if you get stuck.
- Throughout the site you can use conditional HTML to determine whether or not a User has access to the current Course by checking the value of the current User's custom field. You can use that conditional HTML to show / hide content as needed.

Otherwise if you want to implement multiple roles you can utilize the CRED API to trigger any required code when the order is complete. You would need to find out from the Multiple Roles plugin if they offer an API. I wouldn't be able to assist with that part of the code, but I could help explain how to integrate it.

CRED API information here:
https://toolset.com/documentation/programmer-reference/cred-api/

Let me know if you have additional questions about this process.

#586927

thx for the detailed reply, C!
in the end, what i did was user woocommerce membership plugin together with types and views.
i had to do some tweaking (well, a lot of tweaking actually) - but now i'm good.
situation now is, all users are "customers", but i create a membership plan for each course, so a customer can purchase many courses.
thanks!
ido